[1238] | 1 | ## Script (Python) "getPaymentsInfo" |
---|
| 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: getPaymentsFolderInfo.py 1431 2007-02-17 15:42:31Z henrik $ |
---|
| 11 | """ |
---|
| 12 | Info for the PaymentsFolder |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
[1427] | 15 | logger = logging.getLogger('EPayment.Info') |
---|
[1238] | 16 | import DateTime |
---|
| 17 | request = context.REQUEST |
---|
| 18 | students = context.portal_url.getPortalObject().campus.students |
---|
| 19 | |
---|
| 20 | student_id = context.getStudentId() |
---|
| 21 | if student_id is None: |
---|
| 22 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
| 23 | #student = getattr(students,student_id) |
---|
[1338] | 24 | s_brain = context.students_catalog(id = student_id)[0] |
---|
[1427] | 25 | |
---|
[1238] | 26 | payments = [] |
---|
[1283] | 27 | #from Products.zdb import set_trace;set_trace() |
---|
[1427] | 28 | |
---|
[1238] | 29 | info = {} |
---|
| 30 | is_so = info['is_so'] = context.isSectionOfficer() |
---|
[1427] | 31 | |
---|
| 32 | res = context.portal_catalog(portal_type='Student',id = student_id) |
---|
| 33 | if res: |
---|
| 34 | info['review_state'] = res[0].review_state |
---|
| 35 | |
---|
[1238] | 36 | info['student_name'] = s_brain.name |
---|
[1427] | 37 | payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id) |
---|
| 38 | sos = context.portal_catalog(container_path=payments_path) |
---|
| 39 | info['is_so'] = is_so |
---|
| 40 | |
---|
| 41 | for so in sos: |
---|
| 42 | |
---|
| 43 | row = {} |
---|
| 44 | row['id'] = so.getId |
---|
| 45 | row['title'] = so.Title |
---|
| 46 | url = row['url'] = "%s/%s" % (payments_path,so.getId) |
---|
| 47 | so_object = context.restrictedTraverse(url,default=None).getContent() |
---|
| 48 | row['type'] = so.portal_type |
---|
| 49 | review_state = row['review_state'] = so.review_state |
---|
| 50 | if so_object.type_description.startswith('School Fee'): |
---|
| 51 | row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] == 'cleared_and_validated' |
---|
| 52 | else: |
---|
| 53 | row['is_approvable'] = is_so and (review_state == "opened") |
---|
| 54 | if (review_state == "closed") and so_object.resp_code in ('SC','00','AP',): |
---|
| 55 | row['confirmed'] = 'active' |
---|
| 56 | else: |
---|
[1431] | 57 | row['confirmed'] = 'unsuccessful' |
---|
[1427] | 58 | payments.append(row) |
---|
| 59 | |
---|
| 60 | |
---|
[1238] | 61 | info['payments'] = payments |
---|
| 62 | return info |
---|
[1431] | 63 | |
---|