source: WAeUP_SRP/trunk/skins/waeup_utilities/list_students.py @ 17864

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

some code cleaning

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