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

Last change on this file since 1736 was 1661, checked in by joachim, 18 years ago

fix for #145

  • Property svn:keywords set to Id
File size: 2.3 KB
RevLine 
[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 1661 2007-03-30 08:10:44Z joachim $
11"""
12Info for the PaymentsFolder
13"""
[1568]14#import logging
15#logger = logging.getLogger('Skins.getPaymentsFolderInfo')
[1661]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
[1568]24
[1238]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)
[1338]33s_brain = context.students_catalog(id = student_id)[0]
[1427]34
[1238]35payments = []
[1283]36#from Products.zdb import set_trace;set_trace()
[1427]37
[1238]38info = {}
39is_so = info['is_so'] = context.isSectionOfficer()
[1427]40
41res = context.portal_catalog(portal_type='Student',id = student_id)
42if res:
43    info['review_state'] = res[0].review_state
44
[1238]45info['student_name'] = s_brain.name
[1427]46payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
47sos = context.portal_catalog(container_path=payments_path)
48info['is_so'] = is_so
49
50for so in sos:
51
52    row = {}
53    row['id'] = so.getId
54    row['title'] = so.Title
55    url = row['url'] = "%s/%s" % (payments_path,so.getId)
56    so_object = context.restrictedTraverse(url,default=None).getContent()
57    row['type'] = so.portal_type
58    review_state = row['review_state'] = so.review_state
59    if so_object.type_description.startswith('School Fee'):
60        row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
61    else:
62        row['is_approvable'] = is_so and (review_state == "opened")
[1613]63    if so_object.type_description.startswith('School Fee'):
64        row['is_requeryable'] = (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
65    else:
66        row['is_requeryable'] = is_so and (review_state == "opened")
[1634]67    if (review_state == "closed") and so_object.resp_code in ('SC','00','AP','IP',):
[1427]68        row['confirmed'] = 'active'
69    else:
[1431]70        row['confirmed'] = 'unsuccessful'
[1427]71    payments.append(row)
72
[1661]73payments.sort(cmp_id)
[1238]74info['payments'] = payments
75return info
[1431]76
Note: See TracBrowser for help on using the repository browser.