{% block upleft %}
-
-
+
+
{% endblock upleft %}
diff --git a/loko/mobile/tests.py b/loko/mobile/tests.py
index d9917c4..8541e1e 100644
--- a/loko/mobile/tests.py
+++ b/loko/mobile/tests.py
@@ -65,6 +65,35 @@ class MobileIndexViewTests(TestCase):
self.assertEqual(response.status_code, 200)
self.assertTrue(response.context["can_add_structures_repair"])
+ def test_technician_can_access_home_with_home_param_and_see_assets(self):
+ """Technicians are redirected initially, but can access the home page via ?home=1 or subsequent navigation."""
+ technician_role, _ = Role.objects.get_or_create(name="technician")
+ self.user_config.roles.add(technician_role)
+
+ thematic = Thematic.objects.create(code="signalisation", name_fr="Signalisation", name_nl="Signalisatie")
+ UserThematics.objects.create(
+ user_config=self.user_config,
+ thematic=thematic,
+ can_view_assets=True,
+ can_view_interventions=True
+ )
+
+ # 1. Initial access without ?home redirects to interventions
+ response = self.client.get(reverse("mobile:mobile_index"))
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(response.url, "/mobile/interventions/")
+
+ # 2. Access with ?home=1 allows viewing the home page
+ response = self.client.get(reverse("mobile:mobile_index") + "?home=1")
+ self.assertEqual(response.status_code, 200)
+ self.assertTrue(response.context["can_view_assets"])
+ self.assertContains(response, reverse("mobile:mobile_assets_index"))
+ self.assertContains(response, reverse("mobile:interventions_index_mobile"))
+
+ # 3. Subsequent access in the same session without ?home also stays on home
+ response = self.client.get(reverse("mobile:mobile_index"))
+ self.assertEqual(response.status_code, 200)
+
class MobileStockPermissionTests(TestCase):
def setUp(self):
diff --git a/loko/mobile/views.py b/loko/mobile/views.py
index a8ea837..7ef17dc 100644
--- a/loko/mobile/views.py
+++ b/loko/mobile/views.py
@@ -40,13 +40,23 @@ def index(request):
user_config = None
try:
user_config = UserConfig.objects.get(user=request.user)
- # Vérifie si l'utilisateur n'a qu'un seul rôle et que c'est 'technician'
roles = list(user_config.roles.values_list('name', flat=True))
- if len(roles) == 1 and roles[0] == 'technician':
- return redirect('/mobile/interventions/')
- # Vérifie si l'utilisateur n'a qu'un seul rôle et que c'est 'observer'
- if len(roles) == 1 and roles[0] == 'observer':
- return redirect('/mobile/observations/')
+
+ # Les techniciens (et observateurs) sont redirigés directement sur leur page de travail
+ # lors de leur arrivée initiale dans la session (/mobile/), mais peuvent accéder à la page d'accueil ensuite
+ # (ex: clic sur l'icône Accueil ?home=1, navigation interne depuis la session, etc.)
+ wants_home = request.GET.get('home') == '1' or request.session.get('mobile_home_visited', False)
+ if not wants_home:
+ # Vérifie si l'utilisateur n'a qu'un seul rôle et que c'est 'technician'
+ if len(roles) == 1 and roles[0] == 'technician':
+ request.session['mobile_home_visited'] = True
+ return redirect('/mobile/interventions/')
+ # Vérifie si l'utilisateur n'a qu'un seul rôle et que c'est 'observer'
+ if len(roles) == 1 and roles[0] == 'observer':
+ request.session['mobile_home_visited'] = True
+ return redirect('/mobile/observations/')
+ else:
+ request.session['mobile_home_visited'] = True
except UserConfig.DoesNotExist:
# If no user config exists, return unauthorized (403)
diff --git a/loko/notifications/templates/notifications/inbox_mobile.html b/loko/notifications/templates/notifications/inbox_mobile.html
index a9dc042..dd3d503 100644
--- a/loko/notifications/templates/notifications/inbox_mobile.html
+++ b/loko/notifications/templates/notifications/inbox_mobile.html
@@ -115,7 +115,7 @@
-
+
{% translate "Accueil" %}