Skip to content

Commit

Permalink
www: Add new GPS item to nav bar
Browse files Browse the repository at this point in the history
When the employer/prescriber's organization department is 30
  • Loading branch information
tonial committed Feb 7, 2025
1 parent 544a351 commit e91f563
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion itou/templates/utils/templatetags/nav.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load matomo %}

<ul class="nav nav-tabs flex-column">
<ul class="nav nav-tabs flex-column" id="nav-menu">
{% for menu_group_or_item in menu_items %}
{% if menu_group_or_item.items %}
<li class="nav-item">
Expand Down
18 changes: 18 additions & 0 deletions itou/utils/templatetags/nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from django.urls import reverse
from django.utils.text import slugify

from itou.www.gps.views import is_allowed_to_use_gps


register = template.Library()

Expand Down Expand Up @@ -190,6 +192,16 @@ def __repr__(self):
matomo_event_name="clic",
matomo_event_option="annexes-financieres",
),
# GPS (for employers and prescribers with an org in department nb 30
"gps": NavItem(
label="GPS",
icon="ri-compass-line",
target=reverse("gps:my_groups"),
active_view_names=["gps:my_groups", "gps:user_details"],
matomo_event_category="gps",
matomo_event_name="clic",
matomo_event_option="tdb_liste_beneficiaires",
),
}


Expand Down Expand Up @@ -243,6 +255,12 @@ def nav(request):
items=[NAV_ENTRIES["labor-inspector-members"]],
)
)
if (
is_allowed_to_use_gps(request.user)
and request.current_organization
and request.current_organization.department == "30"
):
menu_items.append(NAV_ENTRIES["gps"])
menu_items.append(
NavGroup(
label="Rechercher",
Expand Down
4 changes: 3 additions & 1 deletion itou/www/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def dashboard(request, template_name="dashboard/dashboard.html"):
"can_create_siae_antenna": False,
"can_show_financial_annexes": False,
"can_show_employee_records": False,
"can_view_gps_card": is_allowed_to_use_gps(request.user),
"can_view_gps_card": (
is_allowed_to_use_gps(request.user) and getattr(request.current_organization, "department", None) != "30"
),
"can_view_stats_dashboard_widget": stats_utils.can_view_stats_dashboard_widget(request),
"num_rejected_employee_records": 0,
"pending_prolongation_requests": None,
Expand Down
41 changes: 41 additions & 0 deletions tests/www/dashboard/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,36 +598,71 @@ def test_diagoriente_info_is_shown_in_sidebar_for_job_seeker(self, client):
EmployerFactory,
for_snapshot=True,
with_company=True,
with_company__company__department="75",
),
"card",
],
[
partial(
EmployerFactory,
for_snapshot=True,
with_company=True,
with_company__company__department="30",
),
"nav",
], # in the Gard
[partial(PrescriberFactory, for_snapshot=True), "card"], # no org
[
partial(
PrescriberFactory,
for_snapshot=True,
membership=True,
membership__organization__authorized=False,
membership__organization__department="75",
),
"card",
], # non authorizd org
[
partial(
PrescriberFactory,
for_snapshot=True,
membership=True,
membership__organization__authorized=False,
membership__organization__department="30",
),
"nav",
], # non authorizd org in the Gard
[
partial(
PrescriberFactory,
for_snapshot=True,
membership=True,
membership__organization__authorized=True,
membership__organization__department="75",
),
"card",
], # authorized_org
[
partial(
PrescriberFactory,
for_snapshot=True,
membership=True,
membership__organization__authorized=True,
membership__organization__department="30",
),
"nav",
], # authorized_org in the Gard
[partial(LaborInspectorFactory, membership=True), None],
],
ids=[
"job_seeker",
"employer",
"employer_gard",
"prescriber_no_org",
"prescriber_non_authorized_org",
"prescriber_non_authorized_org_gard",
"prescriber",
"prescriber_gard",
"labor_inspector",
],
)
Expand All @@ -642,6 +677,12 @@ def test_gps_card(self, snapshot, client, factory, gps_info):
else:
assertNotContains(response, GPS_CARD_TXT)

nav_menu = str(parse_response_to_soup(response, "#nav-menu"))
if gps_info == "nav":
assert "gps" in nav_menu
else:
assert "gps" not in nav_menu

def test_dashboard_prescriber_without_organization_message(self, client):
# An orienter is a prescriber without prescriber organization
orienter = PrescriberFactory()
Expand Down

0 comments on commit e91f563

Please sign in to comment.