Skip to content

Commit

Permalink
Merge cancel confirmation view with modal
Browse files Browse the repository at this point in the history
  • Loading branch information
xavfernandez committed Oct 17, 2024
1 parent 62f3cf9 commit 8f8302e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 70 deletions.
33 changes: 0 additions & 33 deletions itou/templates/apply/process_cancel.html

This file was deleted.

43 changes: 22 additions & 21 deletions itou/templates/apply/process_details_company.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,10 @@

{% block title_inline_actions %}
{% if can_be_cancelled %}
{% if job_application.to_company.is_subject_to_eligibility_rules %}
<button class="btn btn-danger btn-lg btn-ico ms-auto" data-bs-toggle="modal" data-bs-target="#cancel_hire_modal">
<i class="ri-arrow-go-back-line fw-medium" aria-hidden="true"></i>
<span>Annuler l’embauche</span>
</button>
{% else %}
<a class="btn btn-danger btn-lg btn-ico ms-auto" href="{% url 'apply:cancel' job_application_id=job_application.id %}">
<i class="ri-arrow-go-back-line fw-medium" aria-hidden="true"></i>
<span>Annuler l’embauche</span>
</a>
{% endif %}
<button class="btn btn-danger btn-lg btn-ico ms-auto" data-bs-toggle="modal" data-bs-target="#cancel_hire_modal">
<i class="ri-arrow-go-back-line fw-medium" aria-hidden="true"></i>
<span>Annuler l’embauche</span>
</button>
{% endif %}
{% endblock %}

Expand Down Expand Up @@ -197,7 +190,7 @@ <h5 class="modal-title" id="modal_title_{{ siae.pk }}">Confirmation du transfert
{% endif %}
{% endfor %}
{% endif %}
{% if can_be_cancelled and job_application.to_company.is_subject_to_eligibility_rules %}
{% if can_be_cancelled %}
<div id="cancel_hire_modal" class="modal" tabindex="-1" aria-labelledby="cancel_hire_modal_title" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
Expand All @@ -208,18 +201,26 @@ <h5 class="modal-title" id="cancel_hire_modal_title">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
</div>
<div class="modal-body">
<p>
Si vous annulez cette embauche, vous ne pourrez pas prétendre à l'aide au poste pour les jours éventuellement travaillés.
</p>
<p>
{{ job_application.job_seeker.get_full_name }} restera éligible à l'IAE et pourra de nouveau vous envoyer une candidature dans le futur.
</p>
{% if job_application.to_company.is_subject_to_eligibility_rules %}
<p>
En validant, <strong>vous renoncez aux aides au poste</strong> liées à cette candidature pour tous les jours travaillés de ce salarié.
Si ce salarié a travaillé dans votre structure, il est préférable de suspendre son PASS IAE.
</p>
<p>
{{ job_application.job_seeker.get_full_name }} restera éligible à l'IAE et pourra de nouveau vous envoyer une candidature dans le futur.
</p>
{% else %}
<p>
En annulant cette embauche, vous confirmez que le salarié n’avait pas encore commencé à travailler dans votre structure.
</p>
{% endif %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-outline-secondary" data-bs-dismiss="modal">Annuler</button>
<a href="{% url 'apply:cancel' job_application_id=job_application.id %}" class="btn btn-sm btn-primary">
Annuler l’embauche
</a>
<form method="post" action="{% url 'apply:cancel' job_application_id=job_application.id %}" class="js-prevent-multiple-submit">
{% csrf_token %}
<button class="btn btn-sm btn-primary">Confirmer l’annulation de l’embauche</button>
</form>
</div>
</div>
</div>
Expand Down
25 changes: 9 additions & 16 deletions itou/www/apply/views/process_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ class ReloadJobDescriptionFields(AcceptHTMXFragmentView):


@login_required
def cancel(request, job_application_id, template_name="apply/process_cancel.html"):
@require_POST
def cancel(request, job_application_id):
"""
Trigger the `cancel` transition.
"""
Expand All @@ -552,21 +553,13 @@ def cancel(request, job_application_id, template_name="apply/process_cancel.html
messages.error(request, "Vous ne pouvez pas annuler cette embauche.")
return HttpResponseRedirect(next_url)

if request.method == "POST" and request.POST.get("confirm") == "true":
try:
# After each successful transition, a save() is performed by django-xworkflows.
job_application.cancel(user=request.user)
messages.success(request, "L'embauche a bien été annulée.", extra_tags="toast")
except xwf_models.InvalidTransitionError:
messages.error(request, "Action déjà effectuée.", extra_tags="toast")
return HttpResponseRedirect(next_url)

context = {
"can_view_personal_information": True, # SIAE members have access to personal info
"job_application": job_application,
"matomo_custom_title": "Candidature annulée",
}
return render(request, template_name, context)
try:
# After each successful transition, a save() is performed by django-xworkflows.
job_application.cancel(user=request.user)
messages.success(request, "L'embauche a bien été annulée.", extra_tags="toast")
except xwf_models.InvalidTransitionError:
messages.error(request, "Action déjà effectuée.", extra_tags="toast")
return HttpResponseRedirect(next_url)


@login_required
Expand Down

0 comments on commit 8f8302e

Please sign in to comment.