Last change
on this file since 868 was
868,
checked in by joachim, 19 years ago
|
added student_wf_guard
modified waeup_student_wf to use it.
nothing tested yet, tomorrow more.
|
-
Property svn:keywords set to
Id
|
File size:
1.4 KB
|
Rev | Line | |
---|
[868] | 1 | ## Script (Python) "student_wf_guard" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters=REQUEST, transition, state_change |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: student_wf_guard.py 868 2006-11-14 19:01:25Z joachim $ |
---|
| 11 | """ |
---|
| 12 | check if the current action is allowed by workflow |
---|
| 13 | """ |
---|
| 14 | request = REQUEST |
---|
| 15 | wftool = context.portal_workflow |
---|
| 16 | mtool = context.portal_membership |
---|
| 17 | member = mtool.getAuthenticatedMember() |
---|
| 18 | roles = member.getRolesInContext(context) |
---|
| 19 | def intersection(a,b): |
---|
| 20 | r = [] |
---|
| 21 | for i in a: |
---|
| 22 | if i in b: |
---|
| 23 | r.append(i) |
---|
| 24 | return r |
---|
| 25 | |
---|
| 26 | if transition in ('admit',): |
---|
| 27 | if intersection(('Manager', 'SectionManager'),roles): |
---|
| 28 | return True |
---|
| 29 | return False |
---|
| 30 | if transition in ('apply_for_admission', |
---|
| 31 | 'create_content', |
---|
| 32 | 'enter_application_pin', |
---|
| 33 | 'enter_clearance_pin', |
---|
| 34 | 'pume_fail', |
---|
| 35 | 'pume_pass' |
---|
| 36 | 'request_clearance', |
---|
| 37 | ): |
---|
| 38 | if intersection(('Manager', 'SectionManager','Owner'),roles): |
---|
| 39 | return True |
---|
| 40 | return False |
---|
| 41 | # |
---|
| 42 | # |
---|
| 43 | if transition in ('clear_and_validate', |
---|
| 44 | 'defer', |
---|
| 45 | 'finally_reject', |
---|
| 46 | 'raise_objection', |
---|
| 47 | 'reject_admission', |
---|
| 48 | 'reject_clearance', |
---|
| 49 | ): |
---|
| 50 | if intersection(('Manager', 'SectionManager'),roles)\ |
---|
| 51 | and context.isClearanceOfficer(): |
---|
| 52 | return True |
---|
| 53 | return False |
---|
Note: See
TracBrowser for help on using the repository browser.