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

Candidature: déplacer le bouton “annuler l’embauche” [GEN-2099] #4942

Merged
merged 2 commits into from
Oct 18, 2024
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
39 changes: 22 additions & 17 deletions itou/templates/apply/process_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,28 @@
{% endblock %}

{% block title_content %}
<div class="d-md-flex align-items-center">
<h1 class="mb-1 mb-md-0 me-3">
Candidature de
{% if with_job_seeker_detail_url|default:False %}
<a href="{% url "job_seekers_views:details" public_id=job_application.job_seeker.public_id %}?back_url={{ request.get_full_path|urlencode }}" class="btn-link">{{ job_application.job_seeker.get_full_name|mask_unless:can_view_personal_information }}</a>
{% else %}
{{ job_application.job_seeker.get_full_name|mask_unless:can_view_personal_information }}
{% endif %}
</h1>
{% state_badge job_application extra_class="badge-base" %}
<button class="btn btn-lg btn-ico-only btn-link"
type="button"
data-it-action="print"
{% matomo_event "candidature" "click" "impression-fiche-candidature" %}
aria-label="Imprimer la candidature de {{ job_application.job_seeker.get_full_name|mask_unless:can_view_personal_information }}">
<i class="ri-printer-line fw-normal" aria-hidden="true"></i>
</button>
<div class="d-flex flex-column flex-md-row gap-3 mb-3 justify-content-md-between">
<div class="d-xl-flex align-items-xl-center">
<h1 class="mb-0 me-3 text-md-nowrap">
Candidature de
{% if with_job_seeker_detail_url|default:False %}
<a href="{% url "job_seekers_views:details" public_id=job_application.job_seeker.public_id %}?back_url={{ request.get_full_path|urlencode }}" class="btn-link">{{ job_application.job_seeker.get_full_name|mask_unless:can_view_personal_information }}</a>
{% else %}
{{ job_application.job_seeker.get_full_name|mask_unless:can_view_personal_information }}
{% endif %}
</h1>
{% state_badge job_application extra_class="badge-base" %}
<button class="btn btn-lg btn-ico-only btn-link"
type="button"
data-it-action="print"
{% matomo_event "candidature" "click" "impression-fiche-candidature" %}
aria-label="Imprimer la candidature de {{ job_application.job_seeker.get_full_name|mask_unless:can_view_personal_information }}">
<i class="ri-printer-line fw-normal" aria-hidden="true"></i>
</button>
</div>
<div>
{% block title_inline_actions %}{% endblock %}
</div>
</div>
{% block actions %}{% endblock %}
{% endblock %}
Expand Down
33 changes: 0 additions & 33 deletions itou/templates/apply/process_cancel.html

This file was deleted.

61 changes: 43 additions & 18 deletions itou/templates/apply/process_details_company.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
</ul>
{% endblock %}

{% block title_inline_actions %}
{% if can_be_cancelled %}
<button class="btn btn-danger btn-lg btn-ico w-100 w-md-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 %}

{% block actions %}
{% include "apply/includes/siae_hiring_actions.html" with job_application=job_application %}
{% endblock %}
Expand Down Expand Up @@ -100,24 +109,6 @@ <h3>Action préalable à l'embauche</h3>
<div class="col-12 col-lg-4 order-1 order-lg-2 mt-lg-6">
{% block sidebar %}
{{ block.super }}
{# Job application accepted: cancel --------------------------------------------------------------------- #}
{% if job_application.state.is_accepted and job_application.can_be_cancelled %}
<div class="c-box mb-4">
{% if job_application.to_company.is_subject_to_eligibility_rules %}
<h4>Rétractation</h4>
<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>
{% endif %}
<a href="{% url 'apply:cancel' job_application_id=job_application.id %}" class="btn btn-danger btn-block btn-ico text-decoration-none">
<i class="ri-arrow-go-back-line fw-medium" aria-hidden="true"></i>
<span>Annuler l'embauche</span>
</a>
</div>
{% endif %}
{% if job_application.to_company.is_subject_to_eligibility_rules and request.user.is_employer and job_application.state.is_accepted and job_application.approval %}
<div class="c-box mb-4">
<h4>PASS IAE</h4>
Expand Down Expand Up @@ -199,6 +190,40 @@ <h5 class="modal-title" id="modal_title_{{ siae.pk }}">Confirmation du transfert
{% endif %}
{% endfor %}
{% endif %}
{% 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">
<div class="modal-header">
<h5 class="modal-title" id="cancel_hire_modal_title">
Annuler l’embauche de {{ job_application.job_seeker.get_full_name }}
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
</div>
<div class="modal-body">
{% 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 validant, 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>
<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-danger">Confirmer l’annulation de l’embauche</button>
</form>
</div>
</div>
</div>
</div>
{% endif %}

{# GEIQ SIAE without valid geiq_eligibility_diagnosis. Modal triggered by apply/includes/buttons/accept.html #}
{% if job_application.to_company.kind == CompanyKind.GEIQ and not geiq_eligibility_diagnosis.is_valid %}
Expand Down
6 changes: 3 additions & 3 deletions itou/utils/staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@
},
"theme-inclusion": {
"download": {
"url": "https://github.com/gip-inclusion/itou-theme/archive/refs/tags/v2.2.8.zip",
"sha256": "1af0c0dc979de28e0fd867e43845d925ea4e6f619bae76904110eedb1da87730",
"url": "https://github.com/gip-inclusion/itou-theme/archive/refs/tags/v2.2.9.zip",
"sha256": "6e750cb96ea6fd378d62539d9984c63f74da46f2d8b4accd70dddabfe4baeffc",
},
"extract": {
"origin": "itou-theme-2.2.8/dist",
"origin": "itou-theme-2.2.9/dist",
"destination": "vendor/theme-inclusion/",
"files": [
"javascripts/app.js",
Expand Down
28 changes: 12 additions & 16 deletions itou/www/apply/views/process_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ def details_for_company(request, job_application_id, template_name="apply/proces
hiring_start_at=job_application.hiring_start_at
)

can_be_cancelled = job_application.state.is_accepted and job_application.can_be_cancelled

context = {
"can_be_cancelled": can_be_cancelled,
"can_view_personal_information": True, # SIAE members have access to personal info
"can_edit_personal_information": request.user.can_edit_personal_information(job_application.job_seeker),
"display_refusal_info": False,
Expand Down Expand Up @@ -578,7 +581,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 @@ -591,21 +595,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
58 changes: 24 additions & 34 deletions tests/www/apply/__snapshots__/test_process.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,18 @@
ORDER BY "approvals_approval"."created_at" DESC
''',
}),
dict({
'origin': list([
'JobApplication.can_be_cancelled[job_applications/models.py]',
'details_for_company[www/apply/views/process_views.py]',
]),
'sql': '''
SELECT %s AS "a"
FROM "employee_record_employeerecord"
WHERE "employee_record_employeerecord"."job_application_id" = %s
LIMIT 1
''',
}),
dict({
'origin': list([
'Company.has_admin[common_apps/organizations/models.py]',
Expand Down Expand Up @@ -1809,23 +1821,6 @@
ORDER BY "approvals_approval"."created_at" DESC
''',
}),
dict({
'origin': list([
'JobApplication.can_be_cancelled[job_applications/models.py]',
'IfNode[apply/process_details_company.html]',
'BlockNode[apply/process_details_company.html]',
'BlockNode[layout/base.html]',
'ExtendsNode[apply/process_base.html]',
'ExtendsNode[apply/process_details_company.html]',
'details_for_company[www/apply/views/process_views.py]',
]),
'sql': '''
SELECT %s AS "a"
FROM "employee_record_employeerecord"
WHERE "employee_record_employeerecord"."job_application_id" = %s
LIMIT 1
''',
}),
dict({
'origin': list([
'ForNode[apply/includes/transition_logs.html]',
Expand Down Expand Up @@ -2693,6 +2688,18 @@
ORDER BY "approvals_approval"."created_at" DESC
''',
}),
dict({
'origin': list([
'JobApplication.can_be_cancelled[job_applications/models.py]',
'details_for_company[www/apply/views/process_views.py]',
]),
'sql': '''
SELECT %s AS "a"
FROM "employee_record_employeerecord"
WHERE "employee_record_employeerecord"."job_application_id" = %s
LIMIT 1
''',
}),
dict({
'origin': list([
'Company.has_admin[common_apps/organizations/models.py]',
Expand Down Expand Up @@ -2790,23 +2797,6 @@
ORDER BY "approvals_approval"."created_at" DESC
''',
}),
dict({
'origin': list([
'JobApplication.can_be_cancelled[job_applications/models.py]',
'IfNode[apply/process_details_company.html]',
'BlockNode[apply/process_details_company.html]',
'BlockNode[layout/base.html]',
'ExtendsNode[apply/process_base.html]',
'ExtendsNode[apply/process_details_company.html]',
'details_for_company[www/apply/views/process_views.py]',
]),
'sql': '''
SELECT %s AS "a"
FROM "employee_record_employeerecord"
WHERE "employee_record_employeerecord"."job_application_id" = %s
LIMIT 1
''',
}),
dict({
'origin': list([
'ForNode[apply/includes/transition_logs.html]',
Expand Down
Loading