Skip to content

Commit

Permalink
gps: Add request for new participant link
Browse files Browse the repository at this point in the history
  • Loading branch information
tonial committed Jan 13, 2025
1 parent 34debb5 commit 35f649f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
12 changes: 11 additions & 1 deletion itou/templates/users/includes/gps_group.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
{% load matomo %}

<div class="c-box mb-3 mb-lg-5" id="gps_intervenants">
<h2 class="border-bottom pb-3">Intervenant{{ gps_memberships|length|pluralizefr }}</h2>
<div class="border-bottom">
<div class="d-flex flex-column flex-md-row gap-3 justify-content-md-between align-items-start">
<h2>Intervenant{{ gps_memberships|length|pluralizefr }}</h2>
<div class="d-flex flex-column flex-md-row gap-3" role="group" aria-label="Actions sur les participants">
<a href="{{ request_new_participant_form_url }}" id="request-new-participant-link" class="btn btn-sm btn-ico btn-primary mt-3 mt-md-0">
<i class="ri-user-add-line" aria-hidden="true"></i>
<span>Ajouter un intervenant existant</span>
</a>
</div>
</div>
</div>
<ul class="list-unstyled p-0 m-0">
{% for membership in gps_memberships %}
<li class="c-box--results__header px-0 gps_intervenant">
Expand Down
21 changes: 21 additions & 0 deletions itou/www/gps/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import urllib.parse

from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from django.db.models import Count
Expand Down Expand Up @@ -146,6 +148,24 @@ def get_context_data(self, **kwargs):

membership = next(m for m in gps_memberships if m.member == self.request.user)

request_new_participant_form_url = (
"https://formulaires.gps.inclusion.gouv.fr/ajouter-intervenant?"
+ urllib.parse.urlencode(
{
"user_name": self.request.user.get_full_name(),
"user_id": self.request.user.pk,
"user_email": self.request.user.email,
"user_organization_name": getattr(self.request.current_organization, "display_name", ""),
"user_organization_id": getattr(self.request.current_organization, "pk", ""),
"user_type": self.request.user.kind,
"beneficiary_name": self.object.get_full_name(),
"beneficiary_id": self.object.pk,
"beneficiary_email": self.object.email,
"success_url": self.request.build_absolute_uri(),
}
)
)

context = context | {
"back_url": back_url,
"gps_memberships": gps_memberships,
Expand All @@ -154,6 +174,7 @@ def get_context_data(self, **kwargs):
"profile": self.object.jobseeker_profile,
"render_advisor_matomo_option": matomo_option,
"matomo_option": "coordonnees-conseiller-" + (matomo_option if matomo_option else "ailleurs"),
"request_new_participant_form_url": request_new_participant_form_url,
}

return context
12 changes: 11 additions & 1 deletion tests/gps/__snapshots__/test_views.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,17 @@


<div class="c-box mb-3 mb-lg-5" id="gps_intervenants">
<h2 class="border-bottom pb-3">Intervenant</h2>
<div class="border-bottom">
<div class="d-flex flex-column flex-md-row gap-3 justify-content-md-between align-items-start">
<h2>Intervenant</h2>
<div aria-label="Actions sur les participants" class="d-flex flex-column flex-md-row gap-3" role="group">
<a aria-label="Ajouter un intervenant existant" class="btn btn-sm btn-ico btn-primary mt-3 mt-md-0" href="https://formulaires.gps.inclusion.gouv.fr/ajouter-intervenant?user_name=Pierre+DUPONT&amp;user_id=[PK of user]&amp;user_email=pierre.dupont%40test.local&amp;user_organization_name=Les+Olivades&amp;user_organization_id=[PK of organization]&amp;user_type=prescriber&amp;beneficiary_name=Jane+DOE&amp;beneficiary_id=[PK of beneficiary]&amp;beneficiary_email=jane.doe%40test.local&amp;success_url=http%3A%2F%2Ftestserver%2Fgps%2Fdetails%2F7614fc4b-aef9-4694-ab17-12324300180a" id="request-new-participant-link">
<i aria-hidden="true" class="ri-user-add-line"></i>
<span>Ajouter un intervenant existant</span>
</a>
</div>
</div>
</div>
<ul class="list-unstyled p-0 m-0">

<li class="c-box--results__header px-0 gps_intervenant">
Expand Down
19 changes: 17 additions & 2 deletions tests/gps/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,19 @@ def test_beneficiary_details(client, snapshot):

user_details_url = reverse("gps:user_details", kwargs={"public_id": beneficiary.public_id})
response = client.get(user_details_url)
html_details = parse_response_to_soup(response, selector="#beneficiary_details_container")
html_details = parse_response_to_soup(
response,
selector="#beneficiary_details_container",
replace_in_attr=[
("href", f"user_id={prescriber.pk}", "user_id=[PK of user]"),
(
"href",
f"user_organization_id={prescriber.prescribermembership_set.get().pk}",
"user_organization_id=[PK of organization]",
),
("href", f"beneficiary_id={beneficiary.pk}", "beneficiary_id=[PK of beneficiary]"),
],
)
assert str(html_details) == snapshot
user_dropdown_menu = parse_response_to_soup(response, selector="div#dashboardUserDropdown")

Expand All @@ -319,7 +331,10 @@ def test_beneficiary_details(client, snapshot):
prescriber.phone = ""
prescriber.save()
response = client.get(user_details_url)
assert "Téléphone non renseigné" in str(response.content.decode())
assertContains(response, "Téléphone non renseigné")

assertContains(response, "Ajouter un intervenant")
assertContains(response, "https://formulaires.gps.inclusion.gouv.fr/ajouter-intervenant")


def test_remove_members_from_group(client):
Expand Down

0 comments on commit 35f649f

Please sign in to comment.