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

Last change on this file since 1831 was 1783, checked in by Henrik Bettermann, 18 years ago
  • assertViewable removed and page templates adjusted, so that no traceback occurs.
  • 'Previous Session' action added
  • waeup_content_master.pt removed
  • and more
  • Property svn:keywords set to Id
File size: 2.5 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 1783 2007-05-15 07:49:50Z henrik $
11"""
12Info for the PaymentsFolder
13"""
14
15mtool = context.portal_membership
16if mtool.isAnonymousUser():
17    return None
18
19
20#import logging
21#logger = logging.getLogger('Skins.getPaymentsFolderInfo')
22def cmp_id(a,b):
23    s1 = "%(id)s" % a
24    s2 = "%(id)s" % b
25    if s1 == s2:
26        return 0
27    if s1 > s2:
28        return 1
29    return -1
30
31import DateTime
32request = context.REQUEST
33students = context.portal_url.getPortalObject().campus.students
34
35student_id = context.getStudentId()
36if student_id is None:
37    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
38#student = getattr(students,student_id)
39s_brain = context.students_catalog(id = student_id)[0]
40
41payments = []
42#from Products.zdb import set_trace;set_trace()
43
44info = {}
45is_so = info['is_so'] = context.isSectionOfficer()
46
47#res = context.portal_catalog(portal_type='Student',id = student_id)
48#res = context.students_catalog(id = student_id)
49info['review_state'] = s_brain.review_state
50session = s_brain.session
51info['next_session'], info['next_session_str'] = context.getNextSessionId(session)
52
53info['student_name'] = s_brain.name
54payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
55sos = context.portal_catalog(container_path=payments_path)
56info['is_so'] = is_so
57
58for so in sos:
59
60    row = {}
61    row['id'] = so.getId
62    row['title'] = so.Title
63    url = row['url'] = "%s/%s" % (payments_path,so.getId)
64    so_object = context.restrictedTraverse(url,default=None).getContent()
65    row['type'] = so.portal_type
66    review_state = row['review_state'] = so.review_state
67    if so_object.type_description.startswith('School Fee'):
68        row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
69    else:
70        row['is_approvable'] = is_so and (review_state == "opened")
71    if so_object.type_description.startswith('School Fee'):
72        row['is_requeryable'] = (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
73    else:
74        row['is_requeryable'] = is_so and (review_state == "opened")
75    if (review_state == "closed") and so_object.resp_code in ('SC','00','AP','IP',):
76        row['confirmed'] = 'active'
77    else:
78        row['confirmed'] = 'unsuccessful'
79    payments.append(row)
80
81payments.sort(cmp_id)
82info['payments'] = payments
83return info
84
Note: See TracBrowser for help on using the repository browser.