source: WAeUP_SRP/trunk/skins/waeup_accommodation/release_bed.py @ 1449

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

modified importReservedBeds
fixReservedBeds
added release_bed
many documentation addons for xml-files

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1## Script (Python) "change_bed"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: release_bed.py 1449 2007-02-20 20:23:34Z joachim $
11"""
12release an allocated bed
13"""
14import logging
15logger = logging.getLogger('Student.Accommodation.release_bed')
16
17request = context.REQUEST
18redirect = request.RESPONSE.redirect
19mtool = context.portal_membership
20wf = context.portal_workflow
21member = mtool.getAuthenticatedMember()
22member_id = str(member)
23path_info = request.get('PATH_INFO').split('/')
24
25if mtool.isAnonymousUser():
26    return None
27students = context.portal_url.getPortalObject().campus.students
28acco_cat = context.portal_accommodation
29#stud_cat = context.students_catalog
30student_id = context.getStudentId()
31
32if student_id is not None:
33    logger.info('"%s", "requests bed_release for", "%s"' % (member_id,student_id))
34    res = acco_cat(student=student_id)
35    if len(res) == 0:
36        logger.info('"%s", "no bed found"' % (student_id))
37        redirect("%s/%s" % (students.absolute_url(),student_id))
38    allocated_bed = res[0]
39    acco_cat.modifyRecord(bed=allocated_bed.bed,student='')
40    acco_doc = context.getContent()
41    acco_doc.edit(mapping={'bed':acco_doc.bed + " (cancelled by release bed %s!)" % member})
42    redirect("%s" % (context.absolute_url()))
43
Note: See TracBrowser for help on using the repository browser.