1 | ## Script (Python) "changeRegState" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=REQUEST,transition=None |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: epayment_cb.py 1348 2007-01-25 17:06:21Z henrik $ |
---|
11 | """ |
---|
12 | execute transition |
---|
13 | """ |
---|
14 | |
---|
15 | mtool = context.portal_membership |
---|
16 | member = mtool.getAuthenticatedMember() |
---|
17 | |
---|
18 | #if str(member) not in ('admin','joachim') or transition is None: |
---|
19 | # return 'Forbidden!' |
---|
20 | |
---|
21 | if not context.isSectionOfficer() or transition is None: |
---|
22 | return 'Forbidden!' |
---|
23 | |
---|
24 | import logging |
---|
25 | logger = logging.getLogger('Skins.changeRegState') |
---|
26 | |
---|
27 | pm = context.portal_membership |
---|
28 | member = pm.getAuthenticatedMember() |
---|
29 | |
---|
30 | request = context.REQUEST |
---|
31 | #students = context.portal_url.getPortalObject().campus.students |
---|
32 | wftool = context.portal_workflow |
---|
33 | student_id = context.getStudentId() |
---|
34 | context_doc = context |
---|
35 | if student_id is None: |
---|
36 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
37 | #student = getattr(students,student_id) |
---|
38 | #context_doc = student |
---|
39 | try: |
---|
40 | wftool.doActionFor(context_doc,transition) |
---|
41 | logger.info('%s executed transition %s for %s' % (member,transition,student_id)) |
---|
42 | except: |
---|
43 | logger.info('%s tried to execute transition %s for %s, transition not allowed' % (member,transition,student_id)) |
---|
44 | return 'Transition not allowed!' |
---|
45 | |
---|
46 | return request.RESPONSE.redirect("%s" % context.absolute_url()) |
---|