Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dépôt de besoin] Simplification du formulaire #909

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions lemarche/templates/tenders/create_step_description.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,6 @@ <h4>Questions à poser aux prestataires ciblés</h4>
<button type="button" class="btn btn-info" x-on:click="addNewQuestion()">Ajouter une question</button>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-7">{% bootstrap_field form.constraints %}</div>
<div class="col-12 col-lg-5">
<div class="c-form-conseil">
<div>
<p>
<i class="ri-lightbulb-line ri-lg mr-1"></i><strong>Conseil</strong>
<br />
Les contraintes techniques spécifiques sont les exigences que vous souhaitez porter à la connaissance des prestataires inclusifs.
</p>
<p>
Plus elles seront précises, plus vous aurez de chances de recevoir des réponses qualitatives des prestataires inclusifs.
</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-7">
<span x-data="SocialImpactCalculatorComponent">
Expand All @@ -96,12 +79,6 @@ <h4>Questions à poser aux prestataires ciblés</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-7">
<label class="fake-label">Co-traitance</label>
{% bootstrap_field form.accept_cocontracting %}
</div>
</div>
{% endblock content_form %}
{% block extra_js %}
<script type="text/javascript"
Expand Down
5 changes: 0 additions & 5 deletions lemarche/templates/tenders/create_step_general.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
{% bootstrap_field form.sectors form_group_class="form-group form-group-required use-multiselect" %}
</div>
</div>
<div class="row">
<div class="col-12 col-lg-7">
{% bootstrap_field form.presta_type %}
</div>
</div>
<div class="row">
<div class="col-12 col-lg-7">
<div class="form-group form-group-required {% if form.location.errors %}is-invalid{% endif %}">
Expand Down
34 changes: 1 addition & 33 deletions lemarche/templates/tenders/create_step_survey.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block step_title %}Evaluation de l’impact{% endblock %}
{% block step_title_again %}Evaluation de l’impact{% endblock %}
{% block step_subtitle %}
Aidez-nous à évaluer l'impact de la plateforme du Marché de l’inclusion en répondant à ces quelques questions.
Aidez-nous à évaluer l'impact de la plateforme du Marché de l’inclusion en répondant à ces deux questions.
<br />
<i class="fs-sm"> ⚠️ Ces informations sont anonymisées et exploitées à des fins statistiques. Elles resteront strictement confidentielles.</i>
{% endblock %}
Expand All @@ -29,12 +29,6 @@
</div>
<div class="row">
<div class="col-12 col-lg-7">
{% bootstrap_field form.worked_with_inclusif_siae_this_kind_tender form_group_class="form-group mb-lg-5" %}
<div id="div_is_encouraged_by_le_marche"
class="{% if form.worked_with_inclusif_siae_this_kind_tender.value == '1' %}d-none{% endif %}">
{% bootstrap_field form.is_encouraged_by_le_marche form_group_class="form-group form-group-required mb-lg-5" %}
</div>
{% bootstrap_field form.providers_out_of_insertion form_group_class="form-group mb-lg-5" %}
{% bootstrap_field form.le_marche_doesnt_exist_how_to_find_siae form_group_class="form-group" %}
</div>
</div>
Expand All @@ -50,29 +44,3 @@
</button>
</div>
{% endblock submit_btn %}
{% block extra_js %}
<script>
document.addEventListener('DOMContentLoaded', function () {
{% comment %} div of the question 3 {% endcomment %}
let divIsEncouragedByLeMarche = document.getElementById('div_is_encouraged_by_le_marche');

let kindRadios = document.querySelectorAll('input[type=radio][name="survey-worked_with_inclusif_siae_this_kind_tender"]');
kindRadios.forEach(radio => radio.addEventListener('change', () => {
let displayQuestion3 = ["0", "?"].includes(radio.value)
if (displayQuestion3) {
divIsEncouragedByLeMarche.classList.remove('d-none');
question3Response = divIsEncouragedByLeMarche.querySelector('input')
question3Response.required = true;
} else {
divIsEncouragedByLeMarche.classList.add('d-none');
question3Response = divIsEncouragedByLeMarche.querySelector('input')
question3Response.required = false;
question3ResponseChecked = divIsEncouragedByLeMarche.querySelector('input:checked')
if(question3ResponseChecked){
question3ResponseChecked.checked = false;
}
}
}));
});
</script>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.2 on 2023-09-18 08:49

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("tenders", "0055_tender_contact_company_name"),
]

operations = [
migrations.AlterField(
model_name="tender",
name="scale_marche_useless",
field=models.CharField(
choices=[("0", "Non"), ("1", "Peu probablement"), ("2", "Très probablement"), ("3", "Oui")],
default="0",
help_text=(
"Si le Marché de l'inclusion n'existait pas, auriez-vous "
"consulté des prestataires inclusifs* pour ce besoin ?"
),
max_length=2,
verbose_name="Utilité du marché de l'inclusion",
),
),
]
2 changes: 1 addition & 1 deletion lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class Tender(models.Model):
# survey
scale_marche_useless = models.CharField(
verbose_name="Utilité du marché de l'inclusion",
help_text="Q°1. Si le Marché de l'inclusion n'existait pas, auriez-vous consulté des prestataires inclusifs* pour ce besoin ?", # noqa
help_text="Si le Marché de l'inclusion n'existait pas, auriez-vous consulté des prestataires inclusifs* pour ce besoin ?", # noqa
max_length=2,
choices=tender_constants.SURVEY_SCALE_QUESTION_CHOICES,
default=tender_constants.SURVEY_SCALE_QUESTION_0,
Expand Down
12 changes: 2 additions & 10 deletions lemarche/www/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,38 +307,30 @@ def csrf_failure(request, reason=""): # noqa C901
if not key.startswith(("csrfmiddlewaretoken", "tender_create_multi_step_view")):
value = formtools_session_step_data.get(step).get(key)
key_cleaned = key.replace(f"{step}-", "")
if key_cleaned in [
"le_marche_doesnt_exist_how_to_find_siae",
"providers_out_of_insertion",
"worked_with_inclusif_siae_this_kind_tender",
"is_encouraged_by_le_marche",
]:
if key_cleaned == "le_marche_doesnt_exist_how_to_find_siae":
tender_dict["extra_data"] |= {key_cleaned: value[0]}
elif key_cleaned == "location":
tender_dict[key_cleaned] = Perimeter.objects.get(slug=value[0])

elif key_cleaned in [
"is_country_area",
"accept_share_amount",
"accept_cocontracting",
]:
tender_dict[key_cleaned] = value[0] == "on"

elif key_cleaned == "sectors":
tender_dict[key_cleaned] = Sector.objects.filter(slug__in=value)
elif key_cleaned not in [
"presta_type",
"response_kind",
"is_country_area",
"accept_share_amount",
"accept_cocontracting",
]:
if value[0]:
tender_dict[key_cleaned] = value[0]
elif key_cleaned == "is_draft":
tender_dict["status"] = tender_constants.STATUS_DRAFT
tender_dict["published_at"] = None
else: # presta_type, response_kind, marche_benefits
else: # response_kind, marche_benefits
tender_dict[key_cleaned] = list() if value[0] == "" else value
# get user
if not request.user.is_authenticated:
Expand Down
40 changes: 1 addition & 39 deletions lemarche/www/tenders/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,13 @@ class TenderCreateStepGeneralForm(forms.ModelForm):
to_field_name="slug",
required=True,
)
presta_type = forms.MultipleChoiceField(
label="Type(s) de prestation(s)",
choices=Tender._meta.get_field("presta_type").base_field.choices,
widget=forms.CheckboxSelectMultiple,
required=True,
)

class Meta:
model = Tender
fields = [
"kind",
"title",
"sectors",
"presta_type",
"location", # generated by js
"is_country_area",
]
Expand Down Expand Up @@ -78,11 +71,9 @@ class Meta:
"description",
"start_working_date",
"external_link",
"constraints",
"amount",
"why_amount_is_blank",
"accept_share_amount",
"accept_cocontracting",
]
widgets = {
"start_working_date": forms.widgets.DateInput(attrs={"class": "form-control", "type": "date"}),
Expand All @@ -108,11 +99,8 @@ def __init__(self, kind, questions_list=None, *args, **kwargs):
self.fields["external_link"].help_text = None
self.fields["amount"].label = "Montant € estimé de votre besoin"
self.fields["accept_share_amount"].label = self.fields["accept_share_amount"].help_text
self.fields["accept_cocontracting"].label = self.fields["accept_cocontracting"].help_text
self.fields["external_link"].widget.attrs["placeholder"] = "https://www.example.fr"
self.fields["constraints"].widget.attrs["placeholder"] = "Ex : Déplacements"
self.fields["accept_share_amount"].help_text = None
self.fields["accept_cocontracting"].help_text = None

def clean_questions_list(self):
questions = self.cleaned_data["questions_list"]
Expand Down Expand Up @@ -235,29 +223,8 @@ class TenderCreateStepSurveyForm(forms.ModelForm):
required=True,
)

worked_with_inclusif_siae_this_kind_tender = forms.ChoiceField(
label="Q°2. Avez-vous déjà travaillé avec des prestataires inclusifs sur ce type de prestation ?",
choices=tender_constants.SURVEY_YES_NO_DONT_KNOW_CHOICES,
widget=forms.RadioSelect,
required=True,
)
# hidden if worked_with_inclusif_siae_this_kind_tender is no or don't know
is_encouraged_by_le_marche = forms.ChoiceField(
label="Q°3. Est-ce la plateforme du Marché de l'inclusion qui vous a encouragé à consulter des prestataires inclusifs pour ce besoin ?", # noqa
choices=tender_constants.SURVEY_ENCOURAGED_BY_US_CHOICES,
widget=forms.RadioSelect,
required=False,
)

providers_out_of_insertion = forms.ChoiceField(
label="Q°4. Comptez-vous consulter d'autres prestataires en dehors de l'Insertion et du Handicap ?",
choices=tender_constants.SURVEY_SCALE_QUESTION_CHOICES,
widget=forms.RadioSelect,
required=True,
)

le_marche_doesnt_exist_how_to_find_siae = forms.CharField(
label="Q°5. Si le Marché de l'inclusion n'existait pas, comment auriez-vous fait pour trouver un prestataire inclusif ?", # noqa
label="Si le Marché de l'inclusion n'existait pas, comment auriez-vous fait pour trouver un prestataire inclusif ?", # noqa
required=False,
widget=forms.Textarea(attrs={"rows": 2, "cols": 15, "data-expandable": "true"}),
)
Expand All @@ -271,11 +238,6 @@ class Meta:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.instance.id:
self.initial["worked_with_inclusif_siae_this_kind_tender"] = self.instance.extra_data.get(
"worked_with_inclusif_siae_this_kind_tender"
)
self.initial["is_encouraged_by_le_marche"] = self.instance.extra_data.get("is_encouraged_by_le_marche")
self.initial["providers_out_of_insertion"] = self.instance.extra_data.get("providers_out_of_insertion")
self.initial["le_marche_doesnt_exist_how_to_find_siae"] = self.instance.extra_data.get(
"le_marche_doesnt_exist_how_to_find_siae"
)
Expand Down
5 changes: 0 additions & 5 deletions lemarche/www/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def _generate_fake_data_form(
"general-kind": tender_not_saved.kind,
"general-title": tender_not_saved.title,
"general-sectors": cls.sectors,
"general-presta_type": siae_constants.PRESTA_BUILD,
"general-location": cls.location_slug,
"general-is_country_area": tender_not_saved.is_country_area,
} | _step_1
Expand All @@ -52,7 +51,6 @@ def _generate_fake_data_form(
"description-description": tender_not_saved.description,
"description-start_working_date": tender_not_saved.start_working_date,
"description-external_link": tender_not_saved.external_link,
"description-constraints": tender_not_saved.constraints,
"description-amount": tender_constants.AMOUNT_RANGE_1000_MORE,
} | _step_2
step_3 = {
Expand All @@ -68,9 +66,6 @@ def _generate_fake_data_form(
step_4 = {
"tender_create_multi_step_view-current_step": "survey",
"survey-scale_marche_useless": tender_constants.SURVEY_SCALE_QUESTION_0,
"survey-worked_with_inclusif_siae_this_kind_tender": tender_constants.SURVEY_DONT_KNOW,
"survey-is_encouraged_by_le_marche": tender_constants.SURVEY_NOT_ENCOURAGED_ONLY_BY_US,
"survey-providers_out_of_insertion": tender_constants.SURVEY_SCALE_QUESTION_2,
"survey-le_marche_doesnt_exist_how_to_find_siae": "TEST",
} | _step_4

Expand Down