fix perm
authorOlivier Larchevêque <olivier.larcheveque@auf.org>
Thu, 19 Jan 2012 15:50:41 +0000 (10:50 -0500)
committerOlivier Larchevêque <olivier.larcheveque@auf.org>
Thu, 19 Jan 2012 15:50:41 +0000 (10:50 -0500)
project/rh/lib.py

index 44c092f..ce61728 100644 (file)
@@ -49,17 +49,10 @@ class ProtectRegionMixin(object):
         return qs.none()
 
     def has_change_permission(self, request, obj=None):
-        if request.user.is_superuser:
+        if obj is None:
             return True
-
-        if obj:
-            employe = get_employe_from_user(request.user)
-            if employe.implantation.region in obj.get_regions():
-                return True
-            else:
-                return False
-
-        return True
+        ids = [o.id for o in self.queryset(request)]
+        return obj.id in ids
 
 
 # Inlines