Commits

Kai Diefenbach  committed 1c47277

State.get_allowed_transitions: try to use the object's has_permissions method before using the one from the utils

  • Participants
  • Parent commits 09da0b9

Comments (0)

Files changed (1)

File workflows/models.py

         transitions = []
         for transition in self.transitions.all():
             permission = transition.permission
-            if permission is None or permissions.utils.has_permission(obj, user, permission.codename):
+            if permission is None:
                transitions.append(transition)
-
+            else:
+                # First we try to get the objects specific has_permission
+                # method (in case the object inherits from the PermissionBase
+                # class).
+                try:
+                    if obj.has_permission(user, permission.codename):
+                        transitions.append(transition)
+                except AttributeError:
+                    if permissions.utils.has_permission(obj, user, permission.codename):
+                        transitions.append(transition)
         return transitions
 
 class Transition(models.Model):