def _allow_sign_document(context):
    """Callable on class to check if document is open for signatures.
    
    Used in bungeni/ui/menu.zcml to filter out 'sign document action'
    """
    manager = interfaces.ISignatoryManager(context)
    return ((manager.can_sign() and manager.allow_signature()) or
            (manager.is_signatory() and not manager.is_consented_signatory()))
def _allow_withdraw_signature(context):
    """Callable on class to check if current user is a signatory.
    We also check that the document allows signature actions.
    Used in bungeni/ui/menu.zcml to filter out 'review signature'
    action.
    """
    manager = interfaces.ISignatoryManager(context)
    return ((manager.document_submitted() or manager.auto_sign())
            and manager.is_consented_signatory() and not manager.is_owner())
def signatory_created(ob, event):
    manager = interfaces.ISignatoryManager(ob.head)
    if manager.document_submitted() or manager.auto_sign():
        IPrincipalRoleMap(ob).assignRoleToPrincipal(OWNER_ROLE, ob.owner.login)
        IPrincipalRoleMap(ob.head).assignRoleToPrincipal(
            SIGNATORY_ROLE, ob.owner.login)
def doc_workflow(ob, event):
    wfc = IWorkflowController(ob, None)
    if wfc:
        manager = interfaces.ISignatoryManager(ob)
        manager.fire_workflow_actions()