source: WAeUP_SRP/trunk/skins/waeup_utilities/payment_export.py @ 17950

Last change on this file since 17950 was 5163, checked in by Henrik Bettermann, 15 years ago

some code cleaning

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1# $Id: payment_export.py 5163 2010-04-21 04:38:00Z henrik $
2"""
3export students who paid for the transfer form
4"""
5
6try:
7    from Products.zdb import set_trace
8except:
9    def set_trace():
10        pass
11
12from Products.AdvancedQuery import Eq, Between, Le,In
13request = context.REQUEST
14setheader = request.RESPONSE.setHeader
15scat = context.students_catalog
16fields = ("id",
17          "name",
18          "matric_no",
19          "jamb_reg_no",
20#          "sex",
21          "email",
22#          "phone",
23#          "faculty",
24#          "department",
25          "course",
26          "level",
27          "session",
28          "review_state",
29          "entry_session",
30          "payment_id",
31          "payment_title",
32          "indexdata",
33          )
34res_list = []
35lines = []
36lines.append(','.join(fields))
37format = '"%(' + ')s","%('.join(fields) + ')s"'
38
39portal = context.portal_catalog_real
40aq_portal = context.portal_catalog_real.evalAdvancedQuery
41payments = aq_portal(Eq('portal_type','Payment') & Eq("review_state","closed"))
42
43#payments = context.portal_catalog(portal_type='Payment')
44
45#return len(payments)
46
47for payment in payments:
48    #if not payment.id.startswith('transfer'):
49    #    continue
50    sid = payment.getPath().split('/')[-3]
51    if not sid:
52        continue
53    erg = scat(id=sid)
54    if not erg:
55        continue
56    d = context.getFormattedStudentEntry(erg[0])
57    indexdata = portal.getIndexDataForRID(payment.getRID())
58    d['payment_id'] = payment.id
59    d['payment_title'] = payment.title
60    d['indexdata'] = indexdata['SearchableText']
61    lines.append(format % d)
62
63#setheader('Content-type', 'text/x-cvs')
64#setheader('Content-type','application/vnd.ms-excel')
65setheader('Content-type','text/semicolon-seperated-values')
66setheader('Content-Disposition:', 'attachment; filename="transfer_list.csv"')
67setheader('Expires',  'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
68setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
69setheader('Cache-Control', 'post-check=0,pre-check=0')
70setheader('Pragma', 'no-cache') # HTTP/1.0
71return '\n'.join(lines)
72
Note: See TracBrowser for help on using the repository browser.