1 | ## Script (Python) "hall_allocation_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: list_students.py 1312 2007-01-17 08:27:39Z joachim $ |
---|
11 | """ |
---|
12 | export student_list |
---|
13 | """ |
---|
14 | request = context.REQUEST |
---|
15 | setheader = request.RESPONSE.setHeader |
---|
16 | pa = context.portal_accommodation |
---|
17 | scat = context.students_catalog |
---|
18 | st_schema = context.students_catalog.schema() |
---|
19 | #fields = list(st_schema) + ["bed",] |
---|
20 | fields = ("id", |
---|
21 | "name", |
---|
22 | "matric_no", |
---|
23 | "jamb_reg_no", |
---|
24 | "sex", |
---|
25 | "email", |
---|
26 | "faculty", |
---|
27 | "department", |
---|
28 | "course", |
---|
29 | "level", |
---|
30 | ) |
---|
31 | res_list = [] |
---|
32 | lines = [] |
---|
33 | lines.append(','.join(fields)) |
---|
34 | format = '"%(' + ')s","%('.join(fields) + ')s"' |
---|
35 | cleared = context.portal_catalog(review_state = "cleared_and_validated") |
---|
36 | for student in cleared: |
---|
37 | erg = scat(id=student.getId) |
---|
38 | if not erg: |
---|
39 | continue |
---|
40 | d = context.getFormattedStudentEntry(erg[0]) |
---|
41 | lines.append(format % d) |
---|
42 | #setheader('Content-type', 'text/x-cvs') |
---|
43 | #setheader('Content-type','application/vnd.ms-excel') |
---|
44 | setheader('Content-type','text/semicolon-seperated-values') |
---|
45 | setheader('Content-Disposition:', 'attachment; filename="cleared_students.csv"') |
---|
46 | setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past |
---|
47 | setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 |
---|
48 | setheader('Cache-Control', 'post-check=0,pre-check=0') |
---|
49 | setheader('Pragma', 'no-cache') # HTTP/1.0 |
---|
50 | return '\n'.join(lines) |
---|