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

Last change on this file since 1587 was 1312, checked in by joachim, 18 years ago

new list_students.py exports all cleared students as csv (in custom)

  • Property svn:keywords set to Id
File size: 1.5 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 1312 2007-01-17 08:27:39Z joachim $
11"""
12export student_list
13"""
14request = context.REQUEST
15setheader = request.RESPONSE.setHeader
16pa = context.portal_accommodation
17scat = context.students_catalog
18st_schema = context.students_catalog.schema()
19#fields = list(st_schema) + ["bed",]
20fields = ("id",
21          "name",
22          "matric_no",
23          "jamb_reg_no",
24          "sex",
25          "email",
26          "faculty",
27          "department",
28          "course",
29          "level",
30          )
31res_list = []
32lines = []
33lines.append(','.join(fields))
34format = '"%(' + ')s","%('.join(fields) + ')s"'
35cleared = context.portal_catalog(review_state = "cleared_and_validated")
36for 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')
44setheader('Content-type','text/semicolon-seperated-values')
45setheader('Content-Disposition:', 'attachment; filename="cleared_students.csv"')
46setheader('Expires',  'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
47setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
48setheader('Cache-Control', 'post-check=0,pre-check=0')
49setheader('Pragma', 'no-cache') # HTTP/1.0
50return '\n'.join(lines)
Note: See TracBrowser for help on using the repository browser.