Multiples zones par user implémenté
[auf_rh_dae.git] / project / decorators.py
index c386666..0424878 100644 (file)
@@ -67,11 +67,9 @@ def region_protected(model):
             if groups.CORRESPONDANT_RH in user_groups or \
                groups.ADMINISTRATEURS in user_groups or \
                groups.DIRECTEUR_DE_BUREAU in user_groups:
-                employe = groups.get_employe_from_user(request.user)
-                q = Q(**{
-                    model.prefix_implantation:
-                    employe.implantation.zone_administrative
-                })
+                zones = groups.get_zones_from_user(request.user)
+                qkey = '%s__in' % model.prefix_implantation
+                q = Q(**{ qkey: zones })
                 qs = model.objects.filter(q)
                 if int(id) in [o.id for o in qs]:
                     return func(request, id)