fix emploi proxy voir
authorOlivier Larchevêque <olivier.larcheveque@auf.org>
Mon, 23 Jul 2012 14:23:03 +0000 (10:23 -0400)
committerOlivier Larchevêque <olivier.larcheveque@auf.org>
Mon, 23 Jul 2012 14:23:03 +0000 (10:23 -0400)
project/assets/css/admin_custom.css
project/recrutement/admin.py

index a74003a..9175f3b 100644 (file)
@@ -1 +1 @@
-#content-main { width: auto; }
+#content-main { width: 100%; }
index 81eb4e3..38bf8d6 100644 (file)
@@ -91,47 +91,62 @@ class OffreEmploiAdminMixin(BaseAdmin):
         user_groupes = [g.name for g in request.user.groups.all()]
 
         # Region
+        
         if 'region' in form.declared_fields:
             region_field = form.declared_fields['region']
-        else:
+            read_only = False
+        elif 'region' in form.base_fields:
             region_field = form.base_fields['region']
-
-        if groups.DRH_NIVEAU_1 in user_groupes or \
-           groups.DRH_NIVEAU_2 in user_groupes or \
-           groups.HAUTE_DIRECTION in user_groupes:
-            region_field.queryset = Region.objects.all()
+            read_only = False
         else:
-            region_field.queryset = Region.objects.\
+            read_only = True
+
+        if not read_only:
+            if groups.DRH_NIVEAU_1 in user_groupes or \
+               groups.DRH_NIVEAU_2 in user_groupes or \
+               groups.HAUTE_DIRECTION in user_groupes:
+                region_field.queryset = Region.objects.all()
+            else:
+                region_field.queryset = Region.objects.\
                                     filter(id=employe.implantation.region.id)
 
         # Poste
         if 'poste' in form.declared_fields:
             poste_field = form.declared_fields['poste']
-        else:
+            read_only = False
+        elif 'poste' in form.base_fields:
             poste_field = form.base_fields['poste']
-
-        if groups.DRH_NIVEAU_1 in user_groupes or \
-           groups.DRH_NIVEAU_2 in user_groupes or \
-           groups.HAUTE_DIRECTION in user_groupes:
-            poste_field.queryset = rh.Poste.objects.all()
+            read_only = False
         else:
-            poste_field.queryset = rh.Poste.objects.\
-                    filter(implantation__region=employe.implantation.region).\
-                    exclude(implantation__in=IMPLANTATIONS_CENTRALES)
+            read_only = True
+
+        if not read_only:
+            if groups.DRH_NIVEAU_1 in user_groupes or \
+               groups.DRH_NIVEAU_2 in user_groupes or \
+               groups.HAUTE_DIRECTION in user_groupes:
+                poste_field.queryset = rh.Poste.objects.all()
+            else:
+                poste_field.queryset = rh.Poste.objects.\
+                        filter(implantation__region=employe.implantation.region).\
+                        exclude(implantation__in=IMPLANTATIONS_CENTRALES)
 
         # Bureau
         if 'bureau' in form.declared_fields:
             bureau_field = form.declared_fields['bureau']
-        else:
+            read_only = False
+        elif 'bureau' in form.base_fields:
             bureau_field = form.base_fields['bureau']
-
-        if groups.DRH_NIVEAU_1 in user_groupes or \
-            groups.DRH_NIVEAU_2 in user_groupes or \
-            groups.HAUTE_DIRECTION in user_groupes:
-            bureau_field.queryset = Bureau.objects.all()
+            read_only = False
         else:
-            bureau_field.queryset = \
-                    Bureau.objects.filter(region=employe.implantation.region)
+            read_only = True
+        if not read_only:
+            if groups.DRH_NIVEAU_1 in user_groupes or \
+                groups.DRH_NIVEAU_2 in user_groupes or \
+                groups.HAUTE_DIRECTION in user_groupes:
+                bureau_field.queryset = Bureau.objects.all()
+            else:
+                bureau_field.queryset = \
+                        Bureau.objects.filter(region=employe.implantation.region)
 
         return form
 
@@ -236,7 +251,7 @@ class ProxyOffreEmploiAdmin(OffreEmploiAdminMixin):
 
     ### Formulaire
     def get_form(self, request, obj=None, **kwargs):
-        form = super(OffreEmploiAdmin, self).get_form(request, obj, **kwargs)
+        form = super(ProxyOffreEmploiAdmin, self).get_form(request, obj, **kwargs)
         return form
 
     ### Permissions add, delete, change