Rev | Line | |
---|
[1871] | 1 | ## Script (Python) "get_searchable_student_states" |
---|
[874] | 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters=key=None |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: get_searchable_student_states.py 3903 2009-02-03 08:19:08Z henrik $ |
---|
| 11 | """ |
---|
| 12 | return the searchable student_states depending on context |
---|
| 13 | """ |
---|
| 14 | wftool = context.portal_workflow |
---|
| 15 | mtool = context.portal_membership |
---|
| 16 | member = mtool.getAuthenticatedMember() |
---|
| 17 | roles = member.getRolesInContext(context) |
---|
| 18 | voc = context.portal_vocabularies.searchable_student_states |
---|
[875] | 19 | if key is not None: |
---|
| 20 | return voc.get(key) |
---|
[3903] | 21 | voc_filtered = [('all', 'all states')] |
---|
[875] | 22 | if "ClearanceOfficers" in member.getGroups(): |
---|
[3903] | 23 | voc_filtered += [item for item in voc.items() if item[0].startswith('clear')] |
---|
| 24 | if "CourseAdvisers" in member.getGroups(): |
---|
| 25 | voc_filtered += [item for item in voc.items() if item[0].startswith('courses')] |
---|
[874] | 26 | |
---|
[3903] | 27 | if len(voc_filtered) > 1: |
---|
| 28 | return voc_filtered |
---|
| 29 | else: |
---|
| 30 | return voc.items() |
---|
[874] | 31 | |
---|
[3903] | 32 | |
---|
Note: See
TracBrowser for help on using the repository browser.