def getMessage(self): """Check signatories validator and generate status message of the form {"level": <level> , "message_text": "<i18n_message>"} """ message = {"level": "info", "message_text": u""} validator = ISignatoryManager(self.context, None) if validator is None: return message if validator.require_signatures(): if validator.validate_consented_signatories(): message["message_text"] = _( "signature_requirement_met", default=( u"This document has the required number of " u"signatories. ${signed_members} member(s) have signed" u". ${required_members} signature(s) required."), mapping={ "signed_members": validator.consented_signatories, "required_members": validator.min_signatories }) else: message["level"] = "warning" message["message_text"] = _( "signature_requirements_not_met", default=(u"This document does not have the required " u"number of signatories. Requires " u"${required_members} signature(s). " u"${signed_members} member(s) have signed."), mapping={ "required_members": validator.min_signatories, "signed_members": validator.consented_signatories }) return message
def getMessage(self): """Check signatories validator and generate status message of the form {"level": <level> , "message_text": "<i18n_message>"} """ message = {"level": "info", "message_text": u""} validator = ISignatoryManager(self.context, None) if validator is None: return message if validator.require_signatures(): if validator.validate_consented_signatories(): message["message_text"] = _("signature_requirement_met", default=(u"This document has the required number of " u"signatories. ${signed_members} member(s) have signed" u". ${required_members} signature(s) required." ), mapping = { "signed_members": validator.consented_signatories, "required_members": validator.min_signatories } ) else: message["level"] = "warning" message["message_text"] = _("signature_requirements_not_met", default=(u"This document does not have the required " u"number of signatories. Requires " u"${required_members} signature(s). " u"${signed_members} member(s) have signed." ), mapping={ "required_members": validator.min_signatories, "signed_members": validator.consented_signatories } ) return message
def pi_allow_signature_actions(context): """allow/disallow other signature actions => such as withdraw and reject """ manager = ISignatoryManager(context.head, None) if manager is not None: return (user_is_context_owner(context, context.owner.user_id) and (manager.document_submitted() or manager.auto_sign()) and user_is_not_parent_document_owner(context)) return False
def pi_allow_signature_actions(context): """allow/disallow other signature actions => such as withdraw and reject """ manager = ISignatoryManager(context.head, None) if manager is not None: return (utils.user_is_context_owner(context) and (manager.document_submitted() or manager.auto_sign()) and user_is_not_parent_document_owner(context)) return False
def pi_unsign_signature(context): manager = ISignatoryManager(context.head, None) if manager: return ((pi_document_redrafted(context) and user_is_not_parent_document_owner(context)) ) return False
def signatory_auto_sign(context): """Determines whether signature is automatically signed when a signatory is added. Whenever the signature is that of the document owner, we auto sign. Also, signature is signed if parent document is created on behalf of a member. The assumption is that the user has provided a list of consented signatories to the document. """ if user_is_parent_document_owner(context): return True # if user adding signatory is not parent document owner, then auto sign #!+SIGNATORIES(mb, aug-2011) this could be tricky versus checking if parent # document is in a 'working_draft' state if user_is_not_context_owner(context.head): return True #!+(mb, Jul-2012) move all signatory logic to signatory manager if ISignatoryManager(context.head).auto_sign(): return True return False
def pi_signatories_check(context): manager = ISignatoryManager(context, None) if manager is not None: return manager.validate_consented_signatories() return True
def pi_has_signatories(context): manager = ISignatoryManager(context, None) if manager is not None: return manager.validate_signatories() return True
def handle_sign_document(self, action, data): user_id = get_db_user_id() manager = ISignatoryManager(self.context) manager.sign_document(user_id) self.request.response.redirect(self.nextURL())
def _can_review_signature(self, action): manager = ISignatoryManager(self.context) return manager.is_signatory(get_db_user_id())
def pi_allow_signature(context): manager = ISignatoryManager(context.head, None) if manager is not None: return (user_is_context_owner(context, context.owner.user_id) and manager.allow_signature()) return False
def pi_allow_signature(context): manager = ISignatoryManager(context.head, None) if manager is not None: return utils.user_is_context_owner(context) and manager.allow_signature() return False
def pi_document_redrafted(context): """Parent document has been redrafted""" manager = ISignatoryManager(context.head, None) return manager and manager.document_is_draft()
def pi_signature_period_expired(context): """The document has been submitted""" manager = ISignatoryManager(context.head, None) if manager is not None: return manager.expire_signatures() return False
def _can_sign_document(self, action): manager = ISignatoryManager(self.context) return manager.can_sign()