## Script (Python) "student_wf_guard" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=REQUEST, transition, state_change ##title= ## # $Id: student_wf_guard.py 868 2006-11-14 19:01:25Z joachim $ """ check if the current action is allowed by workflow """ request = REQUEST wftool = context.portal_workflow mtool = context.portal_membership member = mtool.getAuthenticatedMember() roles = member.getRolesInContext(context) def intersection(a,b): r = [] for i in a: if i in b: r.append(i) return r if transition in ('admit',): if intersection(('Manager', 'SectionManager'),roles): return True return False if transition in ('apply_for_admission', 'create_content', 'enter_application_pin', 'enter_clearance_pin', 'pume_fail', 'pume_pass' 'request_clearance', ): if intersection(('Manager', 'SectionManager','Owner'),roles): return True return False # # if transition in ('clear_and_validate', 'defer', 'finally_reject', 'raise_objection', 'reject_admission', 'reject_clearance', ): if intersection(('Manager', 'SectionManager'),roles)\ and context.isClearanceOfficer(): return True return False