1 | ## Script (Python) "paid_transfer_list" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=student=None |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: hall_allocation_list.py 1273 2007-01-11 18:28:49Z joachim $ |
---|
11 | """ |
---|
12 | export students who paid for the transfer form |
---|
13 | """ |
---|
14 | request = context.REQUEST |
---|
15 | setheader = request.RESPONSE.setHeader |
---|
16 | scat = context.students_catalog |
---|
17 | fields = ("id", |
---|
18 | "name", |
---|
19 | "matric_no", |
---|
20 | "jamb_reg_no", |
---|
21 | "sex", |
---|
22 | "email", |
---|
23 | "phone", |
---|
24 | "faculty", |
---|
25 | "department", |
---|
26 | "course", |
---|
27 | "level", |
---|
28 | ) |
---|
29 | res_list = [] |
---|
30 | lines = [] |
---|
31 | lines.append(','.join(fields)) |
---|
32 | format = '"%(' + ')s","%('.join(fields) + ')s"' |
---|
33 | |
---|
34 | payments = context.portal_catalog(portal_type='Payment') |
---|
35 | |
---|
36 | for payment in payments: |
---|
37 | if not payment.id.startswith('transfer'): |
---|
38 | continue |
---|
39 | sid = payment.getPath().split('/')[-3] |
---|
40 | erg = scat(id=sid) |
---|
41 | if not erg: |
---|
42 | continue |
---|
43 | d = context.getFormattedStudentEntry(erg[0]) |
---|
44 | lines.append(format % d) |
---|
45 | |
---|
46 | #setheader('Content-type', 'text/x-cvs') |
---|
47 | #setheader('Content-type','application/vnd.ms-excel') |
---|
48 | setheader('Content-type','text/semicolon-seperated-values') |
---|
49 | setheader('Content-Disposition:', 'attachment; filename="transfer_list.csv"') |
---|
50 | setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past |
---|
51 | setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 |
---|
52 | setheader('Cache-Control', 'post-check=0,pre-check=0') |
---|
53 | setheader('Pragma', 'no-cache') # HTTP/1.0 |
---|
54 | return '\n'.join(lines) |
---|
55 | |
---|