source: WAeUP_SRP/trunk/skins/waeup_student/list_students.py @ 1851

Last change on this file since 1851 was 1700, checked in by joachim, 18 years ago

students_catalog reindexing implemented.

  • 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 1700 2007-04-23 21:16:34Z joachim $
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
20aq_portal = context.portal_catalog.evalAdvancedQuery
21aq_students = context.students_catalog.evalAdvancedQuery
22request = context.REQUEST
23setheader = request.RESPONSE.setHeader
24pa = context.portal_accommodation
25scat = context.students_catalog
26st_schema = context.students_catalog.schema()
27#fields = list(st_schema) + ["bed",]
28fields = ("id",
29          "name",
30          "matric_no",
31          "jamb_reg_no",
32          "sex",
33          "email",
34          "faculty",
35          "department",
36          "course",
37          "level",
38          )
39res_list = []
40lines = []
41lines.append(','.join(fields))
42format = '"%(' + ')s","%('.join(fields) + ')s"'
43#cleared = context.portal_catalog(review_state = "cleared_and_validated")
44query = In('review_state',('cleared_and_validated',
45                           'school_fee_paid',
46                           'courses_registered',
47                           'courses_validated'))
48cleared = aq_portal(query)
49newquery = 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()
57for 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')
69setheader('Content-type','text/semicolon-seperated-values')
70setheader('Content-Disposition:', 'attachment; filename="cleared_students.csv"')
71setheader('Expires',  'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
72setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
73setheader('Cache-Control', 'post-check=0,pre-check=0')
74setheader('Pragma', 'no-cache') # HTTP/1.0
75return '\n'.join(lines)
Note: See TracBrowser for help on using the repository browser.