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 1700 2007-04-23 21:16:34Z joachim $ |
---|
11 | """ |
---|
12 | export student_list |
---|
13 | """ |
---|
14 | try: |
---|
15 | from Products.zdb import set_trace |
---|
16 | except: |
---|
17 | def set_trace(): |
---|
18 | pass |
---|
19 | from Products.AdvancedQuery import Eq, Between, Le,In,MatchRegexp |
---|
20 | aq_portal = context.portal_catalog.evalAdvancedQuery |
---|
21 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
22 | request = context.REQUEST |
---|
23 | setheader = request.RESPONSE.setHeader |
---|
24 | pa = context.portal_accommodation |
---|
25 | scat = context.students_catalog |
---|
26 | st_schema = context.students_catalog.schema() |
---|
27 | #fields = list(st_schema) + ["bed",] |
---|
28 | fields = ("id", |
---|
29 | "name", |
---|
30 | "matric_no", |
---|
31 | "jamb_reg_no", |
---|
32 | "sex", |
---|
33 | "email", |
---|
34 | "faculty", |
---|
35 | "department", |
---|
36 | "course", |
---|
37 | "level", |
---|
38 | ) |
---|
39 | res_list = [] |
---|
40 | lines = [] |
---|
41 | lines.append(','.join(fields)) |
---|
42 | format = '"%(' + ')s","%('.join(fields) + ')s"' |
---|
43 | #cleared = context.portal_catalog(review_state = "cleared_and_validated") |
---|
44 | query = In('review_state',('cleared_and_validated', |
---|
45 | 'school_fee_paid', |
---|
46 | 'courses_registered', |
---|
47 | 'courses_validated')) |
---|
48 | cleared = aq_portal(query) |
---|
49 | newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*') |
---|
50 | #newquery = MatchRegexp('SearchableText','^5*') |
---|
51 | #new_students = aq_portal(newquery) |
---|
52 | #set_trace() |
---|
53 | #new_sids = [] |
---|
54 | #for ns in new_students: |
---|
55 | # new_sids.append(ns.getPath().split('/')[-2]) |
---|
56 | #set_trace() |
---|
57 | for student in cleared: |
---|
58 | ## if student.getId not in new_sids: |
---|
59 | ## continue |
---|
60 | erg = scat(id=student.getId) |
---|
61 | if not erg: |
---|
62 | continue |
---|
63 | if not erg[0].jamb_reg_no.startswith('6'): |
---|
64 | continue |
---|
65 | d = context.getFormattedStudentEntry(erg[0]) |
---|
66 | lines.append(format % d) |
---|
67 | #setheader('Content-type', 'text/x-cvs') |
---|
68 | #setheader('Content-type','application/vnd.ms-excel') |
---|
69 | setheader('Content-type','text/semicolon-seperated-values') |
---|
70 | setheader('Content-Disposition:', 'attachment; filename="cleared_students.csv"') |
---|
71 | setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past |
---|
72 | setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 |
---|
73 | setheader('Cache-Control', 'post-check=0,pre-check=0') |
---|
74 | setheader('Pragma', 'no-cache') # HTTP/1.0 |
---|
75 | return '\n'.join(lines) |
---|