Skip to content

Commit

Permalink
www.apply: flatten wizard.steps object
Browse files Browse the repository at this point in the history
  • Loading branch information
xavfernandez committed Feb 10, 2025
1 parent bd3ff22 commit 16c759f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
30 changes: 15 additions & 15 deletions itou/templates/apply/process_refuse.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ <h1 class="mb-1 mb-md-0 me-3">
<div class="col-12 col-lg-8">
<div class="c-stepper mb-3 mb-lg-5">
<div class="progress progress--emploi">
<div class="progress-bar progress-bar-{{ wizard.steps|stepper_progress }}" role="progressbar" aria-valuenow="{{ wizard.steps|stepper_progress }}" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-{{ wizard_steps|stepper_progress }}" role="progressbar" aria-valuenow="{{ wizard_steps|stepper_progress }}" aria-valuemin="0" aria-valuemax="100">
</div>
</div>
<p>
{% if wizard.steps.current == RefuseViewStep.REASON %}
<strong>Étape {{ wizard.steps.step1 }}</strong>/{{ wizard.steps.count }} : Choix du motif de refus
{% elif wizard.steps.current == RefuseViewStep.JOB_SEEKER_ANSWER %}
<strong>Étape {{ wizard.steps.step1 }}</strong>/{{ wizard.steps.count }} : Message {{ job_seeker_nb|pluralizefr:"au candidat,aux candidats" }}
{% elif wizard.steps.current == RefuseViewStep.PRESCRIBER_ANSWER %}
<strong>Étape {{ wizard.steps.step1 }}</strong>/{{ wizard.steps.count }} : Message {{ to_prescriber }}
{% if wizard_steps.current == RefuseViewStep.REASON %}
<strong>Étape {{ wizard_steps.step1 }}</strong>/{{ wizard_steps.count }} : Choix du motif de refus
{% elif wizard_steps.current == RefuseViewStep.JOB_SEEKER_ANSWER %}
<strong>Étape {{ wizard_steps.step1 }}</strong>/{{ wizard_steps.count }} : Message {{ job_seeker_nb|pluralizefr:"au candidat,aux candidats" }}
{% elif wizard_steps.current == RefuseViewStep.PRESCRIBER_ANSWER %}
<strong>Étape {{ wizard_steps.step1 }}</strong>/{{ wizard_steps.count }} : Message {{ to_prescriber }}
{% endif %}
</p>
</div>
<div class="c-form mb-3 mb-lg-5">
<form method="post" class="js-prevent-multiple-submit">
{% csrf_token %}

{% if wizard.steps.current == RefuseViewStep.REASON %}
{% if wizard_steps.current == RefuseViewStep.REASON %}
<h2 class="mb-3 mb-md-4">Choix du motif de refus</h2>
<p class="mb-3 mb-md-4">
{% if with_prescriber %}
Expand All @@ -58,7 +58,7 @@ <h2 class="mb-3 mb-md-4">Choix du motif de refus</h2>
Dans le cadre d’un parcours IAE, la transparence sur les motifs de refus est importante pour {{ job_seeker_nb|pluralizefr:"le candidat,les candidats" }}.
{% endif %}
</p>
{% elif wizard.steps.current == RefuseViewStep.JOB_SEEKER_ANSWER %}
{% elif wizard_steps.current == RefuseViewStep.JOB_SEEKER_ANSWER %}
<h2 class="mb-3 mb-md-4">Réponse {{ job_seeker_nb|pluralizefr:"au candidat,aux candidats" }}</h2>
<p class="mb-3 mb-md-4">
{% if with_prescriber %}
Expand All @@ -74,7 +74,7 @@ <h2 class="mb-3 mb-md-4">Réponse {{ job_seeker_nb|pluralizefr:"au candidat,aux
<em>(Motif non communiqué {{ job_seeker_nb|pluralizefr:"au candidat,aux candidats" }})</em>
{% endif %}
</p>
{% elif wizard.steps.current == RefuseViewStep.PRESCRIBER_ANSWER %}
{% elif wizard_steps.current == RefuseViewStep.PRESCRIBER_ANSWER %}
<h2 class="mb-3 mb-md-4">Réponse {{ to_prescriber }}</h2>
<p class="mb-3 mb-md-4">
Vous pouvez partager un message {{ to_prescriber }} uniquement, comme détailler ou évoquer d’autres motifs de refus.
Expand All @@ -88,7 +88,7 @@ <h2 class="mb-3 mb-md-4">Réponse {{ to_prescriber }}</h2>
</p>
{% endif %}

{% if wizard.steps.current == RefuseViewStep.REASON %}
{% if wizard_steps.current == RefuseViewStep.REASON %}
<fieldset class="js-refusal-reasons form-group{% if form.refusal_reason.field.required %} form-group-required{% endif %}">
<legend class="fs-base fw-bold">
{{ form.refusal_reason.label }} :
Expand Down Expand Up @@ -142,10 +142,10 @@ <h2 class="mb-3 mb-md-4">Réponse {{ to_prescriber }}</h2>
{% bootstrap_form form alert_error_type="non_fields" %}
{% endif %}

{% if wizard.steps.prev %}
{% itou_buttons_form reset_url=reset_url primary_label=wizard.steps.next|yesno:"Suivant,Confirmer le refus" secondary_url=wizard.steps.prev matomo_category="candidature" matomo_action="submit" matomo_name=matomo_event_name %}
{% if wizard_steps.prev %}
{% itou_buttons_form reset_url=reset_url primary_label=wizard_steps.next|yesno:"Suivant,Confirmer le refus" secondary_url=wizard_steps.prev matomo_category="candidature" matomo_action="submit" matomo_name=matomo_event_name %}
{% else %}
{% itou_buttons_form reset_url=reset_url primary_label=wizard.steps.next|yesno:"Suivant,Confirmer le refus" matomo_category="candidature" matomo_action="submit" matomo_name=matomo_event_name %}
{% itou_buttons_form reset_url=reset_url primary_label=wizard_steps.next|yesno:"Suivant,Confirmer le refus" matomo_category="candidature" matomo_action="submit" matomo_name=matomo_event_name %}
{% endif %}
</form>
</div>
Expand All @@ -157,7 +157,7 @@ <h2 class="mb-3 mb-md-4">Réponse {{ to_prescriber }}</h2>

{% block script %}
{{ block.super }}
{% if wizard.steps.current == RefuseViewStep.REASON %}
{% if wizard_steps.current == RefuseViewStep.REASON %}
<script nonce="{{ CSP_NONCE }}">
function manageWarningSection(value) {
if (value === 'no_position') {
Expand Down
18 changes: 8 additions & 10 deletions itou/www/apply/views/batch_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ def get_context_data(self, **kwargs):
to_prescriber = "aux prescripteurs/orienteurs"
the_prescriber = "les prescripteurs/orienteurs"

# Compatible with formtools wizard.steps object to share stepper_progress implementation
Steps = namedtuple("Steps", ["current", "step1", "count", "next", "prev"])
if self.tunnel == RefuseTunnel.BATCH:
matomo_custom_title = "Candidatures refusées"
Expand All @@ -372,16 +373,13 @@ def get_context_data(self, **kwargs):
"can_view_personal_information": True, # SIAE members have access to personal info
"matomo_custom_title": matomo_custom_title,
"matomo_event_name": matomo_event_name,
# Compatibility with current process_refuse.html
"wizard": {
"steps": Steps(
current=self.step,
step1=self.steps.index(self.step) + 1,
count=len(self.steps),
next=self.next_step,
prev=self.get_step_url(self.get_previous_step()) if self.get_previous_step() is not None else None,
),
},
"wizard_steps": Steps(
current=self.step,
step1=self.steps.index(self.step) + 1,
count=len(self.steps),
next=self.next_step,
prev=self.get_step_url(self.get_previous_step()) if self.get_previous_step() is not None else None,
),
"form": self.form,
"reset_url": self.reset_url,
"RefuseViewStep": RefuseViewStep,
Expand Down

0 comments on commit 16c759f

Please sign in to comment.