source: WAeUP_SRP/base/skins/waeup_epayment/approve_epayment.py @ 2884

Last change on this file since 2884 was 2656, checked in by Henrik Bettermann, 17 years ago

Several modifications made to enable payment for all sessions, all payment modes and both portals I tested all combinations.

'N/A' replaced by in level, verdict and session widgets. A missing value is now always .

File size: 2.4 KB
Line 
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"""
13import logging
14logger = logging.getLogger('Skins.approve_epayment')
15import DateTime
16if context.portal_membership.isAnonymousUser():
17    return None
18
19request = context.REQUEST
20students = context.portal_url.getPortalObject().campus.students
21wftool = context.portal_workflow
22mtool = context.portal_membership
23is_anon = mtool.isAnonymousUser()
24member = mtool.getAuthenticatedMember()
25student_id = context.getStudentId()
26is_so = context.isSectionOfficer()
27if student_id is None or not is_so:
28    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
29
30student = getattr(students,student_id)
31
32s_brain = context.students_catalog(id=student_id)[0]
33session = s_brain.session
34
35next_info = context.getNextInfo(s_brain)
36next_session_id = next_info['next_session_id']
37next_session_str = next_info['next_session_str']
38next_level_id = next_info['next_level_id']
39next_transition = next_info['next_transition']
40next_verdict = next_info['next_verdict']
41
42pd = {}
43#from Products.zdb import set_trace;set_trace()
44doc = context.getContent()
45review_state = wftool.getInfoFor(context,'review_state',None)
46if review_state != "opened":
47    return "not opened %s" % review_state
48pd['resp_code'] = 'AP'
49pd['resp_desc'] = 'Payment approved by %s, %s' % (member,DateTime.DateTime())
50doc.edit(mapping=pd)
51
52if doc.type_description.startswith('School Fee'):
53    study_course = getattr(student,'study_course')
54    try:
55        wftool.doActionFor(study_course,'open')
56    except:
57        pass
58    verdict = s_brain.verdict
59    if verdict == 'N/A':
60        verdict = ''
61    study_course.getContent().edit(mapping= {'current_level': next_level_id,
62                                             'current_session': next_session_id,
63                                             'current_verdict': next_verdict,
64                                             'previous_verdict': verdict,
65                                             })
66    if next_transition:
67        wftool.doActionFor(student,next_transition)
68
69logger.info('%s approves epayment for %s' % (member,student_id))
70wftool.doActionFor(context,'close')
71return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url())
Note: See TracBrowser for help on using the repository browser.