[#3165] Remplacé les filtres et protection par région pour des filtres et protections...
[auf_rh_dae.git] / project / dae / forms.py
index 28de814..e2007a8 100644 (file)
@@ -84,12 +84,7 @@ class BaseInlineFormSetWithInitial(BaseInlineFormSet):
 def _implantation_choices(obj, request):
     # TRAITEMENT NORMAL
     employe = groups.get_employe_from_user(request.user)
-    # SERVICE
-    if groups.is_user_dans_services_centraux(request.user):
-        q = Q(**{'id': employe.implantation_id})
-    # REGION
-    else:
-        q = Q(**{'region': employe.implantation.region})
+    q = Q(**{'zone_administrative': employe.implantation.zone_administrative})
 
     # TRAITEMENT DRH
     user_groupes = [g.name for g in request.user.groups.all()]
@@ -102,18 +97,16 @@ def _implantation_choices(obj, request):
 def _employe_choices(obj, request):
     # TRAITEMENT NORMAL
     employe = groups.get_employe_from_user(request.user)
-    # SERVICE
-    if groups.is_user_dans_services_centraux(request.user):
-        q_dae_region_service = Q(poste__implantation=employe.implantation)
-        q_rh_region_service = Q(poste__implantation=employe.implantation)
-    # REGION
-    else:
-        q_dae_region_service = Q(
-            poste__implantation__region=employe.implantation.region
+    q_dae_region_service = Q(
+        poste__implantation__zone_administrative=(
+            employe.implantation.zone_administrative
         )
-        q_rh_region_service = Q(
-            poste__implantation__region=employe.implantation.region
+    )
+    q_rh_region_service = Q(
+        poste__implantation__zone_administrative=(
+            employe.implantation.zone_administrative
         )
+    )
     # TRAITEMENT DRH
     user_groupes = [g.name for g in request.user.groups.all()]
     if groups.DRH_NIVEAU_1 in user_groupes: