[1568] | 1 | ## Script (Python) "approve_epayment" |
---|
[1427] | 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 |
---|
[1568] | 14 | logger = logging.getLogger('Skins.approve_epayment') |
---|
[1427] | 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 | |
---|
[2656] | 32 | s_brain = context.students_catalog(id=student_id)[0] |
---|
| 33 | session = s_brain.session |
---|
| 34 | |
---|
[1427] | 35 | pd = {} |
---|
| 36 | doc = context.getContent() |
---|
| 37 | pd['resp_code'] = 'AP' |
---|
| 38 | pd['resp_desc'] = 'Payment approved by %s, %s' % (member,DateTime.DateTime()) |
---|
[2941] | 39 | pd['status'] = 'paid' |
---|
[1427] | 40 | doc.edit(mapping=pd) |
---|
[2656] | 41 | |
---|
[3467] | 42 | if doc.category == 'schoolfee': |
---|
[5594] | 43 | next_info = context.getNextInfo(s_brain) |
---|
| 44 | next_session_id = next_info['next_session_id'] |
---|
| 45 | next_session_str = next_info['next_session_str'] |
---|
| 46 | next_level_id = next_info['next_level_id'] |
---|
| 47 | next_transition = next_info['next_transition'] |
---|
| 48 | next_verdict = next_info['next_verdict'] |
---|
[3467] | 49 | study_course = getattr(student,'study_course') |
---|
| 50 | try: |
---|
| 51 | wftool.doActionFor(study_course,'open') |
---|
| 52 | except: |
---|
| 53 | pass |
---|
| 54 | verdict = s_brain.verdict |
---|
| 55 | if verdict == 'N/A': |
---|
| 56 | verdict = '' |
---|
| 57 | study_course.getContent().edit(mapping= {'current_level': next_level_id, |
---|
| 58 | 'current_session': next_session_id, |
---|
| 59 | 'current_verdict': next_verdict, |
---|
| 60 | 'previous_verdict': verdict, |
---|
| 61 | }) |
---|
| 62 | if next_transition: |
---|
| 63 | wftool.doActionFor(student,next_transition) |
---|
[2656] | 64 | |
---|
[7069] | 65 | elif doc.category == 'acceptance': |
---|
| 66 | if context.getStudentReviewState() in ('admitted', 'objection_raised'): |
---|
| 67 | logger.info('%s paid acceptance fee' % (student_id)) |
---|
| 68 | current = DateTime.DateTime() |
---|
| 69 | wf = context.portal_workflow |
---|
| 70 | info = context.getClearanceInfo() |
---|
| 71 | wftool.doActionFor(student,'enter_clearance_pin') |
---|
| 72 | context.waeup_tool.changeWorkflowState(info['clear'], 'opened') |
---|
| 73 | context.waeup_tool.changeWorkflowState(info['app'], 'closed') |
---|
| 74 | dc = {} |
---|
| 75 | app_doc = info['app_doc'] |
---|
| 76 | #dc['clr_ac_pin'] = pay_doc.order_id |
---|
| 77 | dc['clr_ac_date'] = current |
---|
| 78 | dc['entry_date'] = current |
---|
| 79 | info['clear_doc'].edit(mapping = dc) |
---|
| 80 | if info['penalty']: |
---|
| 81 | logger.info('%s started late clearance' % (info['id'])) |
---|
| 82 | |
---|
[1568] | 83 | logger.info('%s approves epayment for %s' % (member,student_id)) |
---|
[3240] | 84 | review_state = wftool.getInfoFor(context,'review_state',None) |
---|
| 85 | if review_state == 'opened': |
---|
| 86 | wftool.doActionFor(context,'close') |
---|
[1427] | 87 | return request.RESPONSE.redirect("%s/waeup_document_view" % context.absolute_url()) |
---|