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

Last change on this file since 11110 was 3406, checked in by Henrik Bettermann, 17 years ago

WAeUPTool.py: fix traceback

Accommodation.py: enable import of reserved beds

release_bed.py: remove maintenance fee

reserve_accommodation.py: enable bed change for reserved beds. To be done: check for existing acco object before creating it in line 128

change_bed.py: enable bed change for reserved beds

  • Property svn:keywords set to Id
File size: 1.5 KB
RevLine 
[1566]1## Script (Python) "release_bed"
[1449]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 3406 2008-04-02 07:16:08Z henrik $
11"""
12release an allocated bed
13"""
14import logging
[1566]15logger = logging.getLogger('Skins.release_bed')
[1449]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()
[1460]31try:
32    from Products.zdb import set_trace
33except:
34    def set_trace():
35        return
36#set_trace()
[1449]37if student_id is not None:
[1566]38    logger.info('%s requests bed_release for %s' % (member_id,student_id))
[1449]39    res = acco_cat(student=student_id)
40    if len(res) == 0:
[1566]41        logger.info('no bed of %s found' % (student_id))
[3049]42        return redirect("%s/%s" % (students.absolute_url(),student_id))
[1449]43    allocated_bed = res[0]
[3044]44    acco_cat.modifyRecord(bed=allocated_bed.bed,student=acco_cat.not_occupied)
[1449]45    acco_doc = context.getContent()
[3406]46    acco_doc.edit(mapping={'bed':"-- cancelled by section officer --",'acco_maint_fee':""})
[1566]47    logger.info('%s released bed of %s' % (member_id,student_id))
[3049]48    return redirect("%s" % (context.absolute_url()))
[1449]49
Note: See TracBrowser for help on using the repository browser.