source: WAeUP_SRP/trunk/skins/waeup_accommodation/hall_allocation_list.py @ 2140

Last change on this file since 2140 was 1273, checked in by joachim, 18 years ago

split bedname into hall,block,room,bed add filename

  • Property svn:keywords set to Id
File size: 1.7 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: hall_allocation_list.py 1273 2007-01-11 18:28:49Z joachim $
11"""
12export hall_allocation_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          "hall",
23          "block",
24          "room",
25          "bed",
26          "matric_no",
27          "jamb_reg_no",
28          "sex",
29          "email",
30          "phone",
31          "faculty",
32          "department",
33          "course",
34          "level",
35          )
36res_list = []
37lines = []
38lines.append(','.join(fields))
39format = '"%(' + ')s","%('.join(fields) + ')s"'
40reserved = pa(hall=context.getId())
41for bed in reserved:
42    if bed.student == '':
43        continue
44    erg = scat(id=bed.student)
45    if not erg:
46        continue
47    d = context.getFormattedStudentEntry(erg[0])
48    hall,block,room,bed = bed.bed.split('_')
49    d['hall'] = hall
50    d['block'] = block
51    d['room'] = room
52    d['bed'] = bed
53    lines.append(format % d)
54#setheader('Content-type', 'text/x-cvs')
55#setheader('Content-type','application/vnd.ms-excel')
56setheader('Content-type','text/semicolon-seperated-values')
57setheader('Content-Disposition:', 'attachment; filename="%s.csv"' % hall)
58setheader('Expires',  'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
59setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
60setheader('Cache-Control', 'post-check=0,pre-check=0')
61setheader('Pragma', 'no-cache') # HTTP/1.0
62return '\n'.join(lines)
Note: See TracBrowser for help on using the repository browser.