regionalisation active
authorOlivier Larchevêque <olivier.larcheveque@auf.org>
Thu, 12 Jul 2012 19:14:56 +0000 (15:14 -0400)
committerOlivier Larchevêque <olivier.larcheveque@auf.org>
Thu, 12 Jul 2012 19:14:56 +0000 (15:14 -0400)
project/rh/admin.py

index 6a90877..73f2e0b 100644 (file)
@@ -133,25 +133,22 @@ class ProtectRegionMixin(object):
         if in_drh_or_admin(request.user):
             return qs
 
-        #if user_gere_obj_de_sa_region(request.user):
-        #    region_user = get_region_user(request.user)
-        #    q = Q(**{self.model.prefix_implantation: \
-        #            region_user})
-        #    qs = qs.filter(q).distinct()
-        #    return qs
+        if user_gere_obj_de_sa_region(request.user):
+            region_user = get_region_user(request.user)
+            q = Q(**{self.model.prefix_implantation: \
+                    region_user})
+            qs = qs.filter(q).distinct()
+            return qs
         return qs.none()
 
     def has_add_permission(self, request):
-        return in_drh_or_admin(request.user)
-        #return user_can_add_obj(request.user)
+        return user_can_add_obj(request.user)
 
     def has_change_permission(self, request, obj=None):
-        return in_drh_or_admin(request.user)
-        #return user_can_change_obj(request.user, obj) if obj else True
+        return user_can_change_obj(request.user, obj) if obj else True
 
     def has_delete_permission(self, request, obj=None):
-        return in_drh_or_admin(request.user)
-        #return user_can_delete_obj(request.user, obj) if obj else True
+        return user_can_delete_obj(request.user, obj) if obj else True
 
 
 class DerniereModificationAdmin(admin.ModelAdmin):