src/pyams_content/workflow/__init__.py
changeset 1169 04cf19b3985f
parent 956 a8723fffbaf6
child 1170 49cba50f36cb
equal deleted inserted replaced
1168:3b177d6db9db 1169:04cf19b3985f
    10 # FOR A PARTICULAR PURPOSE.
    10 # FOR A PARTICULAR PURPOSE.
    11 #
    11 #
    12 
    12 
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
    15 
       
    16 # import standard library
       
    17 from datetime import datetime
    15 from datetime import datetime
    18 
    16 
    19 # import interfaces
       
    20 from pyams_content.interfaces import MANAGE_SITE_ROOT_PERMISSION, MANAGE_CONTENT_PERMISSION, \
       
    21     PUBLISH_CONTENT_PERMISSION, CREATE_CONTENT_PERMISSION
       
    22 from pyams_content.interfaces import WEBMASTER_ROLE, PILOT_ROLE, MANAGER_ROLE, OWNER_ROLE, READER_ROLE
       
    23 from pyams_content.shared.common.interfaces import IWfSharedContentRoles, IManagerRestrictions
       
    24 from pyams_content.workflow.interfaces import IContentWorkflow
       
    25 from pyams_security.interfaces import IRoleProtectedObject
       
    26 from pyams_workflow.interfaces import ObjectClonedEvent, IWorkflow, IWorkflowVersions, IWorkflowInfo, \
       
    27     IWorkflowState, IWorkflowStateLabel, IWorkflowPublicationInfo, AUTOMATIC, SYSTEM
       
    28 
       
    29 # import packages
       
    30 from pyams_utils.adapter import adapter_config, ContextAdapter
       
    31 from pyams_utils.date import format_datetime
       
    32 from pyams_utils.registry import utility_config
       
    33 from pyams_utils.request import check_request
       
    34 from pyams_workflow.workflow import Transition, Workflow
       
    35 from pyramid.threadlocal import get_current_registry
    17 from pyramid.threadlocal import get_current_registry
    36 from zope.copy import copy
    18 from zope.copy import copy
    37 from zope.interface import implementer
    19 from zope.interface import implementer
    38 from zope.location import locate
    20 from zope.location import locate
    39 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
    21 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
       
    22 
       
    23 from pyams_content.interfaces import CREATE_CONTENT_PERMISSION, MANAGE_CONTENT_PERMISSION, MANAGE_SITE_ROOT_PERMISSION, \
       
    24     PUBLISH_CONTENT_PERMISSION
       
    25 from pyams_content.interfaces import MANAGER_ROLE, OWNER_ROLE, PILOT_ROLE, READER_ROLE, WEBMASTER_ROLE
       
    26 from pyams_content.shared.common.interfaces import IManagerRestrictions, IWfSharedContentRoles
       
    27 from pyams_content.workflow.interfaces import IContentWorkflow
       
    28 from pyams_security.interfaces import IRoleProtectedObject
       
    29 from pyams_utils.adapter import ContextAdapter, adapter_config
       
    30 from pyams_utils.date import format_datetime
       
    31 from pyams_utils.registry import utility_config
       
    32 from pyams_utils.request import check_request
       
    33 from pyams_workflow.interfaces import AUTOMATIC, IWorkflow, IWorkflowInfo, IWorkflowPublicationInfo, IWorkflowState, \
       
    34     IWorkflowStateLabel, IWorkflowVersions, ObjectClonedEvent, SYSTEM
       
    35 from pyams_workflow.workflow import Transition, Workflow
    40 
    36 
    41 from pyams_content import _
    37 from pyams_content import _
    42 
    38 
    43 
    39 
    44 #
    40 #
   167     # grant access to local content managers
   163     # grant access to local content managers
   168     if principal_id in context.managers:
   164     if principal_id in context.managers:
   169         return True
   165         return True
   170     # grant access to shared tool managers if restrictions apply
   166     # grant access to shared tool managers if restrictions apply
   171     restrictions = IManagerRestrictions(context).get_restrictions(principal_id)
   167     restrictions = IManagerRestrictions(context).get_restrictions(principal_id)
   172     return restrictions and restrictions.check_access(context, permission=CREATE_CONTENT_PERMISSION, request=request)
   168     return restrictions and restrictions.check_access(context, permission=MANAGE_CONTENT_PERMISSION, request=request)
   173 
   169 
   174 
   170 
   175 def can_delete_version(wf, context):
   171 def can_delete_version(wf, context):
   176     """Check if we can delete a draft version"""
   172     """Check if we can delete a draft version"""
   177     request = check_request()
   173     request = check_request()