source: WAeUP_SRP/base/skins/waeup_accommodation/getBedStatusFromHall.py @ 3054

Last change on this file since 3054 was 1289, checked in by Henrik Bettermann, 18 years ago

reallocation repair kit

File size: 1.4 KB
Line 
1## Script (Python) "getBedStatusFromHall"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=code=None
8##title=
9##
10# $Id: change_bed.py 1206 2007-01-05 18:24:56Z joachim $
11"""
12"""
13import logging
14logger = logging.getLogger('Student.Accommodation.change_bed')
15import re
16request = context.REQUEST
17redirect = request.RESPONSE.redirect
18mtool = context.portal_membership
19wf = context.portal_workflow
20member = mtool.getAuthenticatedMember()
21member_id = str(member)
22path_info = request.get('PATH_INFO').split('/')
23
24hall,block,room,bed = code.split('_')
25hres = context.portal_catalog(id = hall)
26if not hres:
27    return None
28h = hres[0].getObject().getContent()
29sex = 'male'
30if block in h.blocks_for_female:
31    sex = 'female'
32room_nr = int(room)
33bt = 're'
34reserved = [(r.split('/')[0],int(r.split('/')[1])) for r in re.split(',|\.| ',h.reserved_rooms)
35                                     if r]
36if (block,room_nr) in reserved:
37    bt = "reserved"
38elif not h.special_handling.startswith("no"):
39    bt = h.special_handling
40elif bed in h.beds_for_fresh:
41    bt = 'fr'
42#elif bed in h.beds_for_returning:
43#    bt = 're'
44elif bed in h.beds_for_final:
45    bt = 'fi'
46if h.special_handling.startswith("no_"):
47    bt += "_" + h.special_handling[3:]
48bt = "%s_%s" % (sex,bt)
49uid = '%s_%s_%d_%s' % (hall,block,room_nr,bed)
50return bt
Note: See TracBrowser for help on using the repository browser.