Les admins de dossiers, employés et postes ne géraient pas bien les permissions deman...
authorEric Mc Sween <eric.mcsween@auf.org>
Wed, 6 Jun 2012 21:12:28 +0000 (17:12 -0400)
committerEric Mc Sween <eric.mcsween@auf.org>
Wed, 6 Jun 2012 21:12:28 +0000 (17:12 -0400)
project/rh/admin.py

index 3b66d1e..5bf3f68 100644 (file)
@@ -1,7 +1,7 @@
 # -*- encoding: utf-8 -*-
 
 import datetime
-        
+
 from django.core.urlresolvers import reverse
 from django.contrib import admin
 from django.conf import settings
@@ -146,10 +146,11 @@ class ProtectRegionMixin(object):
         return user_can_add_obj(request.user)
 
     def has_change_permission(self, request, obj=None):
-        return user_can_change_obj(request.user, obj)
+        return user_can_change_obj(request.user, obj) if obj else True
 
     def has_delete_permission(self, request, obj=None):
-        return user_can_delete_obj(request.user, obj)
+        return user_can_delete_obj(request.user, obj) if obj else True
+
 
 # Inlines
 
@@ -877,7 +878,8 @@ class PosteAdmin(DateRangeMixin, AUFMetadataAdminMixin,
             responsable = ''
 
         try:
-            dossier = obj.responsable.rh_dossiers.all().order_by('-date_debut')[0]
+            dossier = obj.responsable.rh_dossiers.all() \
+                    .order_by('-date_debut')[0]
             employe_id = dossier.employe.id
             employe_html = u"""<br />
                     <a href="%s"
@@ -963,17 +965,17 @@ class ResponsableImplantationAdmin(BaseAdmin):
     readonly_fields = ('nom', )
     fields = ('nom', )
     inlines = (ResponsableInline, )
-    
+
     def _region(self, obj):
         return obj.region.code
     _region.short_description = u"Région"
     _region.admin_order_field = 'region__code'
-    
+
     def _nom(self, obj):
         return obj.nom
     _nom.short_description = u"Implantation"
     _nom.admin_order_field = 'nom'
-    
+
     def _responsable(self, obj):
         try:
             employe = obj.responsable.employe