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