Skip to content

Commit

Permalink
wip: alert header + links with GET parameter
Browse files Browse the repository at this point in the history
- added alert headers ("Vous postulez pour…")
  - companies and job descriptions search results
  - companies and job descriptions cards
- added a GET parameter in the process to keep in
  mind that we are applying for a job seeker
- started working on tests
  • Loading branch information
EwenKorr committed Oct 1, 2024
1 parent 1224b75 commit 1670526
Show file tree
Hide file tree
Showing 14 changed files with 443 additions and 25 deletions.
17 changes: 16 additions & 1 deletion itou/templates/companies/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@

{% block title %}{{ siae.display_name }} {{ block.super }}{% endblock %}

{% block global_messages %}
{{ block.super }}
{% if job_seeker %}
<div class="alert alert-primary fade show " role="status">
<p class="mb-0 text-start w-100">
<i class="ri-arrow-right-line pe-2"></i><strong>Vous postulez actuellement pour {{ job_seeker.get_full_name }}</strong>
</p>
<button class="btn btn-link-white btn-ico position-absolute top-0 end-0" aria-label="Quitter" type="button">
<i class="ri-close-line ri-lg pe-2" aria-hidden="true"></i>
Quitter
</button>
</div>
{% endif %}
{% endblock %}

{% block title_prevstep %}
{% include "layout/previous_step.html" with back_url=back_url only %}
{% endblock %}
Expand All @@ -31,7 +46,7 @@ <h2 class="visually-hidden">Actions rapides</h2>
</div>
{% else %}
<div class="form-group col-12 col-lg-auto">
<a href="{% url 'apply:start' company_pk=siae.pk %}"
<a href="{% url 'apply:start' company_pk=siae.pk %}{% if job_seeker %}?job_seeker={{ job_seeker.public_id }}{% endif %}"
class="btn btn-lg btn-white btn-block btn-ico"
{% matomo_event "candidature" "clic" "start_application" %}
aria-label="Postuler auprès de l'employeur inclusif {{ siae.display_name }}">
Expand Down
6 changes: 4 additions & 2 deletions itou/templates/companies/includes/_card_jobdescription.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<i class="ri-community-line font-weight-medium me-1" aria-hidden="true"></i>
<span class="font-weight-bold">{{ job_description.market_context_description | default:"Entreprise anonyme" }}</span>
{% else %}
<a href="{{ job_description.company.get_card_url }}?back_url={{ request.get_full_path|urlencode }}" class="btn-ico btn-link" {% matomo_event "candidature" "clic" "clic-structure-fichedeposte" %}>
<a href="{{ job_description.company.get_card_url }}?{% if job_seeker %}job_seeker={{ job_seeker.public_id }}&{% endif %}back_url={{ request.get_full_path|urlencode }}"
class="btn-ico btn-link"
{% matomo_event "candidature" "clic" "clic-structure-fichedeposte" %}>
<i class="ri-community-line font-weight-medium" aria-hidden="true"></i>
<span>{{ job_description.company.kind }} - {{ job_description.company.display_name }}</span>
</a>
Expand All @@ -29,7 +31,7 @@
<li class="list-group-item list-group-item-action">
<div class="d-flex flex-column flex-md-row justify-content-md-between">
<div class="order-2 order-md-1">
<a href="{{ job_description.get_absolute_url }}?back_url={{ request.get_full_path|urlencode }}"
<a href="{{ job_description.get_absolute_url }}?{% if job_seeker %}job_seeker={{ job_seeker.public_id }}&{% endif %}back_url={{ request.get_full_path|urlencode }}"
class="font-weight-bold text-decoration-none {% if job_description.is_external %}has-external-link{% else %}stretched-link{% endif %}"
{% if job_description.is_external %} {% matomo_event "candidature" "clic" "clic-card-fichedeposte-externe" %} rel="noopener" target="_blank" aria-label="Visiter l'offre sur le site d'origine" {% else %} {% matomo_event "candidature" "clic" "clic-card-fichedeposte" %} aria-label="Aller vers la description de ce poste" {% endif %}>
{{ job_description.display_name | capfirst }}
Expand Down
6 changes: 3 additions & 3 deletions itou/templates/companies/includes/_card_siae.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h3>{{ siae.display_name }}</h3>
</div>
{% else %}
<div>
<a href="{{ siae.get_card_url }}?back_url={{ request.get_full_path|urlencode }}"
<a href="{{ siae.get_card_url }}?{% if job_seeker %}job_seeker={{ job_seeker.public_id }}&{% endif %}back_url={{ request.get_full_path|urlencode }}"
class="btn btn-outline-primary btn-block w-100 w-md-auto white-space-nowrap"
{% matomo_event "candidature" "clic" "clic-structure" %}>Voir la fiche de l'entreprise</a>
</div>
Expand All @@ -78,7 +78,7 @@ <h3>{{ siae.display_name }}</h3>
<div class="d-flex flex-column flex-md-row justify-content-md-between align-items-md-center">
<p class="mb-3 mb-md-0">Cette structure vous intéresse ?</p>
<a class="btn btn-ico btn-primary"
href="{% url 'apply:start' company_pk=siae.pk %}"
href="{% url 'apply:start' company_pk=siae.pk %}{% if job_seeker %}?job_seeker={{ job_seeker.public_id }}{% endif %}"
{% matomo_event "candidature" "clic" "start_application" %}
aria-label="Postuler auprès de l'employeur inclusif {{ siae.display_name }}">
<i class="ri ri-draft-line" aria-hidden="true"></i>
Expand Down Expand Up @@ -154,7 +154,7 @@ <h3>{{ siae.display_name }}</h3>
<div class="d-flex flex-column flex-md-row justify-content-md-between align-items-md-center">
<p class="mb-3 mb-md-0">Cette structure vous intéresse ?</p>
<a class="btn btn-ico btn-primary"
href="{% url 'apply:start' company_pk=siae.pk %}"
href="{% url 'apply:start' company_pk=siae.pk %}{% if job_seeker %}?job_seeker={{ job_seeker.public_id }}{% endif %}"
{% matomo_event "candidature" "clic" "start_application" %}
aria-label="Postuler auprès de l'employeur inclusif {{ siae.display_name }}">
<i class="ri ri-draft-line" aria-hidden="true"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a href="{% if job.pk %}{% url 'apply:job_application_external_transfer_step_1_job_description_card' job_application_id=job_app_to_transfer.pk job_description_id=job.pk %}{% else %}#{% endif %}?back_url={{ request.get_full_path|urlencode }}"
class="font-weight-bold text-decoration-none stretched-link">{{ job.display_name }}</a>
{% else %}
<a href="{% if job.pk %}{{ job.get_absolute_url }}{% else %}#{% endif %}?back_url={{ request.get_full_path|urlencode }}"
<a href="{% if job.pk %}{{ job.get_absolute_url }}{% else %}#{% endif %}?{% if job_seeker %}job_seeker={{ job_seeker.public_id }}&{% endif %}back_url={{ request.get_full_path|urlencode }}"
class="font-weight-bold text-decoration-none stretched-link"
{% matomo_event "candidature" "clic" "clic-metiers" %}>{{ job.display_name }}</a>
{% endif %}
Expand Down
18 changes: 17 additions & 1 deletion itou/templates/companies/job_description_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@

{% block title %}{{ job.display_name }} - {{ siae.display_name }} {{ block.super }}{% endblock %}

{% block global_messages %}
{{ block.super }}
{% if job_seeker %}
<div class="alert alert-primary fade show " role="status">
<p class="mb-0 text-start w-100">
<i class="ri-arrow-right-line pe-2"></i><strong>Vous postulez actuellement pour {{ job_seeker.get_full_name }}</strong>
</p>
<button class="btn btn-link-white btn-ico position-absolute top-0 end-0" aria-label="Quitter" type="button">
<i class="ri-close-line ri-lg pe-2" aria-hidden="true"></i>
Quitter
</button>
</div>
{% endif %}
{% endblock %}


{% block nb_columns %}8{% endblock %}

{% block title_prevstep %}
Expand Down Expand Up @@ -57,7 +73,7 @@ <h2 class="visually-hidden">Actions rapides</h2>
</div>
{% else %}
<div class="form-group col-12 col-lg-auto">
<a href="{% url "apply:start" company_pk=siae.pk %}?job_description_id={{ job.pk }}"
<a href="{% url "apply:start" company_pk=siae.pk %}?job_description_id={{ job.pk }}{% if job_seeker %}&job_seeker={{ job_seeker.public_id }}{% endif %}"
class="btn btn-lg btn-white btn-block btn-ico"
{% matomo_event "candidature" "clic" "start_application" %}
aria-label="Postuler auprès de l'employeur inclusif {{ siae.display_name }}">
Expand Down
8 changes: 7 additions & 1 deletion itou/templates/search/includes/siaes_search_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
<div class="col-12">
{% include "search/includes/siaes_search_subtitle.html" %}
<div class="d-block w-100">
<form hx-get="{{ request.path }}" hx-trigger="change delay:.5s" hx-include="#id_city" hx-indicator="#job-search-results" hx-target="#job-search-results" hx-swap="outerHTML" hx-push-url="true">
<form hx-get="{{ request.path }}{% if job_seeker %}?job_seeker={{ job_seeker.public_id }}{% endif %}"
hx-trigger="change delay:.5s"
hx-include="#id_city"
hx-indicator="#job-search-results"
hx-target="#job-search-results"
hx-swap="outerHTML"
hx-push-url="true">
<div class="btn-dropdown-filter-group mb-3 mb-md-4">
{% include "includes/btn_dropdown_filter/radio.html" with field=form.distance only %}
{% include "includes/btn_dropdown_filter/checkboxes.html" with field=form.kinds only %}
Expand Down
17 changes: 17 additions & 0 deletions itou/templates/search/siaes_search_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,28 @@
{{ block.super }}
{% endblock %}

{% block global_messages %}
{{ block.super }}
{% if job_seeker %}
<div class="alert alert-primary fade show " role="status">
<p class="mb-0 text-start w-100">
<i class="ri-arrow-right-line pe-2"></i><strong>Vous postulez actuellement pour {{ job_seeker.get_full_name }}</strong>
</p>
<button class="btn btn-link-white btn-ico position-absolute top-0 end-0" aria-label="Quitter" type="button">
<i class="ri-close-line ri-lg pe-2" aria-hidden="true"></i>
Quitter
</button>
</div>
{% endif %}
{% endblock %}


{% block title_content %}<h1>Rechercher un emploi inclusif</h1>{% endblock %}

{% block title_extra %}
<form class="mt-md-4">
{% include "search/includes/siaes_search_form.html" with form=form is_home=False only %}
{% if job_seeker %}<input type="hidden" name="job_seeker" value="{{ job_seeker.public_id }}">{% endif %}
</form>
{% include "search/includes/siaes_search_tabs.html" %}
{% endblock %}
Expand Down
44 changes: 43 additions & 1 deletion itou/www/apply/views/submit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,24 @@ def get(self, request, *args, **kwargs):
else:
self.apply_session.init({"selected_jobs": [job_description.pk]})

# Go directly to step ApplicationJobsView if we're carrying the job seeker public id with us.
if job_seeker_public_id := request.GET.get("job_seeker"):
try:
job_seeker = (
User.objects.filter(kind=UserKind.JOB_SEEKER, public_id=job_seeker_public_id)
.select_related("jobseeker_profile")
.first()
)
except (User.DoesNotExist, ValueError):
pass
else:
return HttpResponseRedirect(
reverse(
"apply:application_jobs",
kwargs={"company_pk": self.company.pk, "job_seeker_public_id": job_seeker.public_id},
)
)

# Warn message if prescriber's authorization is pending
if (
request.user.is_prescriber
Expand Down Expand Up @@ -902,7 +920,6 @@ class ApplicationJobsView(ApplicationBaseView):

def __init__(self):
super().__init__()

self.form = None

def get_initial(self):
Expand Down Expand Up @@ -1753,3 +1770,28 @@ def hire_confirmation(
"is_subject_to_geiq_eligibility_rules": company.kind == CompanyKind.GEIQ,
},
)


class TemporaryApplyForMixin:
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# Create an empty variable to avoid unknown variable template errors in tests
context["job_seeker"] = None
if job_seeker_public_id := self.request.GET.get("job_seeker"):
try:
job_seeker = (
User.objects.filter(kind=UserKind.JOB_SEEKER, public_id=job_seeker_public_id)
.select_related("jobseeker_profile")
.first()
)

# TODO(ewen): check that current user can manage this job seeker
context["job_seeker"] = job_seeker
return context
except ValidationError:
return context
else:
return context

def get_job_seeker_query_string(self):
return {"job_seeker": self.request.GET.get("job_seeker")} if self.request.GET.get("job_seeker", None) else {}
5 changes: 3 additions & 2 deletions itou/www/companies_views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from itou.utils.pagination import pager
from itou.utils.perms.company import get_current_company_or_404
from itou.utils.urls import add_url_params, get_absolute_url, get_safe_url
from itou.www.apply.views.submit_views import TemporaryApplyForMixin
from itou.www.companies_views import forms as companies_forms


Expand Down Expand Up @@ -108,7 +109,7 @@ def report_tally_url(user, company, job_description=None):
### Job description views


class JobDescriptionCardView(TemplateView):
class JobDescriptionCardView(TemporaryApplyForMixin, TemplateView):
template_name = "companies/job_description_card.html"

def setup(self, request, job_description_id, *args, **kwargs):
Expand Down Expand Up @@ -441,7 +442,7 @@ def select_financial_annex(request, template_name="companies/select_financial_an
### Company CRUD views


class CompanyCardView(TemplateView):
class CompanyCardView(TemporaryApplyForMixin, TemplateView):
template_name = "companies/card.html"

def setup(self, request, siae_id, *args, **kwargs):
Expand Down
17 changes: 11 additions & 6 deletions itou/www/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from itou.prescribers.models import PrescriberOrganization
from itou.utils.pagination import pager
from itou.utils.urls import add_url_params
from itou.www.apply.views.submit_views import TemporaryApplyForMixin
from itou.www.search.forms import JobDescriptionSearchForm, PrescriberSearchForm, SiaeSearchForm


Expand All @@ -29,13 +30,17 @@ def employer_search_home(request, template_name="search/siaes_search_home.html")
return render(request, template_name, context)


class EmployerSearchBaseView(FormView):
class EmployerSearchBaseView(TemporaryApplyForMixin, FormView):
form_class = SiaeSearchForm
initial = {"distance": SiaeSearchForm.DISTANCE_DEFAULT}

def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs["data"] = self.request.GET or None
# an extra GET parameter is used: job_seeker. It is not part of the form
# so we pop it.
params_get = self.request.GET.copy()
params_get.pop("job_seeker", None)
kwargs["data"] = params_get or None
return kwargs

def get(self, request, *args, **kwargs):
Expand All @@ -47,10 +52,9 @@ def get_context_data(self, **kwargs):
context = {
"back_url": reverse("search:employers_home"),
"clear_filters_url": add_url_params(
self.request.path,
{"city": kwargs["form"].data.get("city")},
self.request.path, {"city": kwargs["form"].data.get("city")} | self.get_job_seeker_query_string()
),
"filters_query_string": "",
"filters_query_string": urlencode(self.get_job_seeker_query_string()),
"job_descriptions_count": 0,
"siaes_count": 0,
"results_page": [],
Expand Down Expand Up @@ -153,7 +157,8 @@ def form_valid(self, form):
"contract_types": contract_types,
"departments": departments,
"domains": domains,
},
}
| self.get_job_seeker_query_string(),
doseq=True,
),
"results_page": results_and_counts.results_page,
Expand Down
Loading

0 comments on commit 1670526

Please sign in to comment.