Small code refactoring
authorThierry Florac <thierry.florac@onf.fr>
Fri, 22 Jun 2018 12:51:31 +0200
changeset 77 91e0b2a7a544
parent 76 56f01a2bcb32
child 78 57cb8fd801c3
Small code refactoring
src/pyams_workflow/content.py
--- a/src/pyams_workflow/content.py	Fri Jun 22 09:11:25 2018 +0200
+++ b/src/pyams_workflow/content.py	Fri Jun 22 12:51:31 2018 +0200
@@ -172,6 +172,8 @@
                 (self.publication_expiration_date >= now))
 
     def is_visible(self, request=None, check_parent=True):
+        if request is None:
+            request = check_request()
         # associated workflow?
         content = IWorkflowManagedContent(self.__parent__, None)
         if content is not None:
@@ -179,11 +181,9 @@
             if not wf_name:
                 return True
             # check workflow?
-            if content.view_permission:
-                if request is None:
-                    request = check_request()
-                if not request.has_permission(content.view_permission, context=self.__parent__):
-                    return False
+            if content.view_permission and \
+               not request.has_permission(content.view_permission, context=self.__parent__):
+                return False
         else:
             if not request.has_permission(VIEW_PERMISSION, context=self.__parent__):
                 return False