Bugfix: organigramme pour DRH & DRH2
authorJean-Philippe Caissy <jpcaissy@piji.ca>
Tue, 10 Apr 2012 21:01:22 +0000 (16:01 -0500)
committerJean-Philippe Caissy <jpcaissy@piji.ca>
Tue, 10 Apr 2012 21:01:22 +0000 (16:01 -0500)
project/rh/admin.py

index 27d8df8..8ca5aa8 100644 (file)
@@ -930,7 +930,6 @@ class ServiceAdmin(AUFMetadataAdminMixin, admin.ModelAdmin, ArchiveMixin):
     _date_modification.short_description = u'date modification'
     _date_modification.admin_order_field = 'date_modification'
 
-
 class ServiceProxyAdmin(ServiceAdmin):
     list_display = ('nom', '_organigramme')
     list_display_links = ('nom',)
@@ -938,6 +937,18 @@ class ServiceProxyAdmin(ServiceAdmin):
     def has_add_permission(self, obj):
         return False
 
+    def has_change_permission(self, request, obj=None):
+        return in_drh_or_admin(request.user)
+
+    def changelist_view(self, request, extra_context=None):
+        if not request.GET.has_key('status__exact'):
+            q = request.GET.copy()
+            q['archive__exact'] = '0'
+            request.GET = q
+            request.META['QUERY_STRING'] = request.GET.urlencode()
+        return super(ServiceProxyAdmin,self).changelist_view(request,
+                extra_context=extra_context)
+
     def _organigramme(self, obj):
         return """<a href="%s">Organigramme</a>""" % (reverse('rho_service', args=(obj.id,)))
     _organigramme.allow_tags = True
@@ -1096,6 +1107,9 @@ class ImplantationProxyAdmin(admin.ModelAdmin):
     def has_add_permission(self, obj):
         return False
 
+    def has_change_permission(self, request, obj=None):
+        return in_drh_or_admin(request.user)
+
     def _organigramme(self, obj):
         return """<a href="%s">Organigramme</a>""" % (reverse('rho_implantation', args=(obj.id,)))
     _organigramme.allow_tags = True
@@ -1108,6 +1122,9 @@ class RegionProxyAdmin(admin.ModelAdmin):
     def has_add_permission(self, obj):
         return False
 
+    def has_change_permission(self, request, obj=None):
+        return in_drh_or_admin(request.user)
+
     def _organigramme(self, obj):
         return """<a href="%s">Organigramme</a>""" % (reverse('rho_region', args=(obj.id,)))
     _organigramme.allow_tags = True