1 | ## Script (Python) "approve_epayment" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters= |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: aprove_epayment.py 1425 2007-02-15 17:52:01Z joachim $ |
---|
11 | """ |
---|
12 | """ |
---|
13 | import logging |
---|
14 | logger = logging.getLogger('Skins.approve_epayment') |
---|
15 | import DateTime |
---|
16 | if context.portal_membership.isAnonymousUser(): |
---|
17 | return None |
---|
18 | |
---|
19 | request = context.REQUEST |
---|
20 | students = context.portal_url.getPortalObject().campus.students |
---|
21 | wftool = context.portal_workflow |
---|
22 | mtool = context.portal_membership |
---|
23 | is_anon = mtool.isAnonymousUser() |
---|
24 | member = mtool.getAuthenticatedMember() |
---|
25 | student_id = context.getStudentId() |
---|
26 | is_so = context.isSectionOfficer() |
---|
27 | if student_id is None or not is_so: |
---|
28 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
29 | |
---|
30 | student = getattr(students,student_id) |
---|
31 | |
---|
32 | s_brain = context.students_catalog(id=student_id)[0] |
---|
33 | session = s_brain.session |
---|
34 | |
---|
35 | next_info = context.getNextInfo(s_brain) |
---|
36 | next_session_id = next_info['next_session_id'] |
---|
37 | next_session_str = next_info['next_session_str'] |
---|
38 | next_level_id = next_info['next_level_id'] |
---|
39 | next_transition = next_info['next_transition'] |
---|
40 | next_verdict = next_info['next_verdict'] |
---|
41 | |
---|
42 | pd = {} |
---|
43 | doc = context.getContent() |
---|
44 | pd['resp_code'] = 'AP' |
---|
45 | pd['resp_desc'] = 'Payment approved by %s, %s' % (member,DateTime.DateTime()) |
---|
46 | pd['status'] = 'paid' |
---|
47 | doc.edit(mapping=pd) |
---|
48 | |
---|
49 | #if doc.type_description.startswith('School Fee'): |
---|
50 | # study_course = getattr(student,'study_course') |
---|
51 | # try: |
---|
52 | # wftool.doActionFor(study_course,'open') |
---|
53 | # except: |
---|
54 | # pass |
---|
55 | # verdict = s_brain.verdict |
---|
56 | # if verdict == 'N/A': |
---|
57 | # verdict = '' |
---|
58 | # study_course.getContent().edit(mapping= {'current_level': next_level_id, |
---|
59 | # 'current_session': next_session_id, |
---|
60 | # 'current_verdict': next_verdict, |
---|
61 | # 'previous_verdict': verdict, |
---|
62 | # }) |
---|
63 | # if next_transition: |
---|
64 | # wftool.doActionFor(student,next_transition) |
---|
65 | |
---|
66 | logger.info('%s approves epayment for %s' % (member,student_id)) |
---|
67 | review_state = wftool.getInfoFor(context,'review_state',None) |
---|
68 | if review_state == 'opened': |
---|
69 | wftool.doActionFor(context,'close') |
---|
70 | return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url()) |
---|