## Script (Python) "release_bed" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: release_bed.py 3049 2008-01-25 15:38:48Z henrik $ """ release an allocated bed """ import logging logger = logging.getLogger('Skins.release_bed') request = context.REQUEST redirect = request.RESPONSE.redirect mtool = context.portal_membership wf = context.portal_workflow member = mtool.getAuthenticatedMember() member_id = str(member) path_info = request.get('PATH_INFO').split('/') if mtool.isAnonymousUser(): return None students = context.portal_url.getPortalObject().campus.students acco_cat = context.portal_accommodation #stud_cat = context.students_catalog student_id = context.getStudentId() try: from Products.zdb import set_trace except: def set_trace(): return #set_trace() if student_id is not None: logger.info('%s requests bed_release for %s' % (member_id,student_id)) res = acco_cat(student=student_id) if len(res) == 0: logger.info('no bed of %s found' % (student_id)) return redirect("%s/%s" % (students.absolute_url(),student_id)) allocated_bed = res[0] acco_cat.modifyRecord(bed=allocated_bed.bed,student=acco_cat.not_occupied) acco_doc = context.getContent() acco_doc.edit(mapping={'bed':"-- cancelled by section officer --"}) logger.info('%s released bed of %s' % (member_id,student_id)) return redirect("%s" % (context.absolute_url()))