Skip to content

Commit

Permalink
apply: set reset_url to company or job description card
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenKorr committed Oct 17, 2024
1 parent 22242cf commit be7fb0a
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 141 deletions.
2 changes: 1 addition & 1 deletion itou/templates/apply/submit/application/resume.html
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,6 @@
{% if auto_prescription_process %}
{% itou_buttons_form primary_label="Enregistrer" secondary_url=back_url matomo_category="candidature" matomo_action="submit" matomo_name="candidature_employer" %}
{% else %}
{% itou_buttons_form primary_label="Envoyer la candidature" secondary_url=back_url matomo_category="candidature" matomo_action="submit" matomo_name="candidature_"|add:request.user.get_kind_display %}
{% itou_buttons_form primary_label="Envoyer la candidature" secondary_url=back_url reset_url=reset_url matomo_category="candidature" matomo_action="submit" matomo_name="candidature_"|add:request.user.get_kind_display %}
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion itou/templates/apply/submit_step_check_job_seeker_nir.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</div>
{% endif %}
{# Reload this page and show a modal containing more information about the job seeker. #}
{% itou_buttons_form primary_label="Suivant" primary_name="preview" primary_value="1" %}
{% itou_buttons_form primary_label="Suivant" primary_name="preview" primary_value="1" reset_url=reset_url %}
</div>
{% if preview_mode %}
<!-- Modal -->
Expand Down
2 changes: 1 addition & 1 deletion itou/templates/apply/submit_step_job_seeker.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{% include "signup/includes/no_email_link.html" with link_text="Le candidat n'a pas d'e-mail ?" only %}
</div>

{% itou_buttons_form primary_label="Suivant" secondary_url=back_url primary_name="preview" primary_value="1" %}
{% itou_buttons_form primary_label="Suivant" secondary_url=back_url primary_name="preview" primary_value="1" reset_url=reset_url %}
</div>
{% if preview_mode %}
<!-- Modal -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{% bootstrap_form form alert_error_type="all" %}

{% itou_buttons_form primary_label="Continuer" %}
{% itou_buttons_form primary_label="Continuer" reset_url=reset_url %}
</form>

{% endblock %}
30 changes: 17 additions & 13 deletions itou/www/apply/views/submit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,30 @@ def dispatch(self, request, *args, **kwargs):
def get_back_url(self):
return None

def get_reset_url(self):
if self.hire_process or self.auto_prescription_process:
# The employer can come either by creating an application or hiring somebody.
# In both cases, the reset_url adds no value compared to going back to the dashboard.
return reverse("dashboard:index")

try:
selected_jobs = self.apply_session.get("selected_jobs", [])
[job_description] = selected_jobs
except (
KeyError, # No apply_session
ValueError, # No job description, or multiple job descriptions.
):
return reverse("companies_views:card", kwargs={"siae_id": self.company.pk})
return reverse("companies_views:job_description_card", kwargs={"job_description_id": job_description})

def get_context_data(self, **kwargs):
return super().get_context_data(**kwargs) | {
"siae": self.company,
"back_url": self.get_back_url(),
"hire_process": self.hire_process,
"prescription_process": self.prescription_process,
"auto_prescription_process": self.auto_prescription_process,
"reset_url": reverse("dashboard:index"),
"reset_url": self.get_reset_url(),
"is_gps": self.is_gps,
"page_title": "Postuler",
}
Expand Down Expand Up @@ -948,18 +964,6 @@ def get_context_data(self, **kwargs):
"full_content_width": bool(job_descriptions_by_pk),
}

def get_back_url(self):
if self.hire_process or self.auto_prescription_process:
# The employer can come either be creating an application or hiring somebody.
# In both cases, the back_url adds no value compared to going back to the dashboard.
return None
selected_jobs = self.apply_session.get("selected_jobs", [])
try:
[job_description] = selected_jobs
except ValueError: # No job description, or multiple job descriptions.
return reverse("companies_views:card", kwargs={"siae_id": self.company.pk})
return reverse("companies_views:job_description_card", kwargs={"job_description_id": job_description})


class RequireApplySessionMixin:
def dispatch(self, request, *args, **kwargs):
Expand Down
Loading

0 comments on commit be7fb0a

Please sign in to comment.