Index: eUP_SRP/trunk/skins/waeup_accommodation/allocate_reserved_bed.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/allocate_reserved_bed.py	(revision 5617)
+++ 	(revision )
@@ -1,145 +1,0 @@
-##parameters=REQUEST
-# $Id: allocate_reserved_bed.py 1451 2007-02-20 22:17:41Z joachim $
-"""
-process the the accommodation reservation
-"""
-import DateTime
-current = DateTime.DateTime()
-pr = context.portal_registration
-wftool = context.portal_workflow
-lt = context.portal_layouts
-mtool = context.portal_membership
-member = mtool.getAuthenticatedMember()
-acco_cat = context.portal_accommodation
-import logging
-logger = logging.getLogger('Skins.allocate_reserved_bed')
-
-#change = REQUEST.has_key("allocate_and_change")
-change = False
-release = REQUEST.has_key("release")
-allocate = REQUEST.has_key("allocate")
-validate = release or change or (allocate and
-           REQUEST.get("allocate").startswith('Allocate'))
-mode = 'create'
-d = {}
-rendered,psm,ds = lt.renderLayout(layout_id= 'acco_bed_booking',
-                      schema_id= 'acco_bed_booking',
-                      context=context,
-                      mapping=validate and REQUEST,
-                      ob=d,
-                      layout_mode='edit',
-                      commit = False
-                      )
-if psm == 'invalid':
-    psm = "Please correct your input."
-    return context.allocate_reserved_bed_form(rendered = rendered,
-                                 psm = psm,
-                                 #psm = "%s, %s" % (psm,ds),
-                                 mode = mode,
-                                 formaction = "allocate_reserved_bed",
-                                 button = "Allocate Bed",
-                                 ds = ds,
-                                 )
-elif psm == '':
-    return context.allocate_reserved_bed_form(rendered = rendered,
-                                 psm = psm,
-                                 mode = mode,
-                                 formaction = "allocate_reserved_bed",
-                                 button = "Allocate Bed",
-                                 ds = ds,
-                                 )
-elif psm == 'valid':
-    pass
-#from Products.zdb import set_trace;set_trace()
-hall_id = context.getId()
-doc = context.getContent()
-student = ds.get('student')
-sid = ds.get('student_id')
-br = ds.get('block_room')
-block = br[0]
-bl = ds.get('bed_letter')
-bid = "%s_%s_%s" % (hall_id,br,bl)
-res = acco_cat(bed = bid)
-psm = ''
-students = context.portal_url.getPortalObject().campus.students
-student_obj = getattr(students,sid)
-acco_id = "accommodation_%s" % context.getSessionId()[0]
-while True:
-    if not res:
-        psm = "No bed with id %s" % bid
-        break
-    bed_brain = res[0]
-    already = acco_cat(student=sid)
-    if allocate or change:
-        if already and not change:
-            psm = "Student %s has already reserved bed %s" % (sid, already[0].bed)
-            break
-        if not bed_brain.bed_type.endswith("reserved"):
-            psm = "%s is not a reserved bed" % bid
-            break
-        if bed_brain.student and bed_brain.student != acco_cat.not_occupied and not change:
-            psm = "Bed %s already reserved for %s" % (bid,bed_brain.student)
-            break
-        if student.sex and not block in doc.blocks_for_female:
-            psm = "Sex does not match %s" % bid
-            break
-    if release:
-        if acco_id in student_obj.objectIds():
-            acco_doc = getattr(student_obj, acco_id).getContent()
-            if acco_doc.bed == bid:
-                psm = "Student %s has already booked (and paid) bed %s" % (sid, bid)
-                break
-        if not already:
-            psm = "Student %s has no reserved bed" % (sid)
-            break
-        if not bed_brain.bed_type.endswith("reserved"):
-            psm = "%s is not a reserved bed" % bid
-            break
-        if not bed_brain.student:
-            psm = "Bed %s not allocated" % (bid)
-            break
-    break
-
-if psm != '':
-    return context.allocate_reserved_bed_form(rendered = rendered,
-                                 psm = psm,
-                                 mode = mode,
-                                 ds = ds,
-                                 formaction = "allocate_reserved_bed",
-                                 button = "Allocate Bed",
-                                 )
-if change:
-    for bed in already:
-        acco_cat.modifyRecord(bed=bed.bed,student='')
-
-if allocate or change:
-    acco_cat.modifyRecord(bed = bid, student = sid)
-    if acco_id in student_obj.objectIds():
-        acco_doc = getattr(student_obj, acco_id).getContent()
-        acco_doc.edit(mapping={'bed': bid})
-    logger.info('%s booked reserved bed %s for %s' % (member,bid,sid))
-    psm = "Bed %s reserved for %s %s" % (bid,sid,student.name)
-elif release:
-    modify = False
-    if acco_id in student_obj.objectIds():
-        #acco_doc = getattr(student_obj, acco_id).getContent()
-        if acco_doc.bed != bid:
-            modify = True
-    else:
-        modify = True
-    if modify:
-        acco_cat.modifyRecord(bed=bid,student='')
-        logger.info('%s released bed %s booked by %s' % (member,bid,sid))
-        psm = "%s removed from %s" % (student.name,bid)
-    else:
-        psm = "Removing of %s from bed %s failed" % (student.name,bid)
-
-mode = 'view'
-return context.allocate_reserved_bed_form(rendered = "",
-                                 psm = psm,
-                                 mode = mode,
-                                 formaction = "allocate_reserved_bed",
-                                 button = "Next Reservation",
-                                 ds = ds,
-                                 )
-
