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