[#3165] Remplacé les filtres et protection par région pour des filtres et protections...
[auf_rh_dae.git] / project / rh / forms.py
index 272fecb..6333ffe 100644 (file)
@@ -89,8 +89,9 @@ class ResponsableInlineForm(forms.ModelForm):
 
 
 class MasseSalarialeForm(forms.Form):
-    region = forms.ModelChoiceField(
-        label=u'Région', queryset=ref.Region.objects.all(), required=False
+    zone_administrative = forms.ModelChoiceField(
+        label=u'Région', queryset=ref.ZoneAdministrative.objects.all(),
+        required=False
     )
     implantation = forms.ModelChoiceField(
         label=u'Implantation', queryset=ref.Implantation.objects.all(),
@@ -112,10 +113,13 @@ class MasseSalarialeForm(forms.Form):
         )
         if is_user_dans_region(user):
             employe = get_employe_from_user(user)
-            self.fields['region'].queryset = ref.Region.objects.filter(
-                id=employe.implantation.region.id
-            )
+            self.fields['zone_administrative'].queryset = \
+                    ref.ZoneAdministrative.objects.filter(
+                        code=employe.implantation.zone_administrative.code
+                    )
             self.fields['implantation'].queryset = \
                     ref.Implantation.objects.filter(
-                        region=employe.implantation.region
+                        zone_administrative=(
+                            employe.implantation.zone_administrative
+                        )
                     )