source: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/list_students.py @ 9735

Last change on this file since 9735 was 1673, checked in by joachim, 18 years ago

merge up to 1672

  • Property svn:keywords set to Id
File size: 2.3 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 1673 2007-04-09 16:01:51Z 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*')
51new_students = aq_portal(newquery)
52new_sids = []
53for ns in new_students:
54    new_sids.append(ns.getPath().split('/')[-2])
55for student in cleared:
56    if student.getId not in new_sids:
57        continue
58    erg = scat(id=student.getId)
59    if not erg:
60        continue
61    d = context.getFormattedStudentEntry(erg[0])
62    lines.append(format % d)
63#setheader('Content-type', 'text/x-cvs')
64#setheader('Content-type','application/vnd.ms-excel')
65setheader('Content-type','text/semicolon-seperated-values')
66setheader('Content-Disposition:', 'attachment; filename="cleared_students.csv"')
67setheader('Expires',  'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
68setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
69setheader('Cache-Control', 'post-check=0,pre-check=0')
70setheader('Pragma', 'no-cache') # HTTP/1.0
71return '\n'.join(lines)
Note: See TracBrowser for help on using the repository browser.