source: WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentsFolderInfo.py @ 1764

Last change on this file since 1764 was 1758, checked in by joachim, 18 years ago

previous sessions students can now pay their previous sessions schoolfees,
please test if "normal" returning students can still pay.

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
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"""
12Info for the PaymentsFolder
13"""
14#import logging
15#logger = logging.getLogger('Skins.getPaymentsFolderInfo')
16def 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
25import DateTime
26request = context.REQUEST
27students = context.portal_url.getPortalObject().campus.students
28
29student_id = context.getStudentId()
30if student_id is None:
31    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
32#student = getattr(students,student_id)
33s_brain = context.students_catalog(id = student_id)[0]
34
35payments = []
36#from Products.zdb import set_trace;set_trace()
37
38info = {}
39is_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)
43info['review_state'] = s_brain.review_state
44session = s_brain.session
45info['next_session'], info['next_session_str'] = context.getNextSessionId(session)
46
47info['student_name'] = s_brain.name
48payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
49sos = context.portal_catalog(container_path=payments_path)
50info['is_so'] = is_so
51
52for 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
75payments.sort(cmp_id)
76info['payments'] = payments
77return info
78
Note: See TracBrowser for help on using the repository browser.