Index: WAeUP_SRP/trunk/Accommodation.py
===================================================================
--- WAeUP_SRP/trunk/Accommodation.py	(revision 3783)
+++ WAeUP_SRP/trunk/Accommodation.py	(revision 3784)
@@ -74,5 +74,5 @@
                         for bed in 'ABCDEFGH'[:int(hall_doc.beds_per_room)]:
                             room_nr = floor*100 + room
-                            bt = 're'
+                            bt = 'all'
                             if (block,room_nr) in reserved:
                                 bt = "reserved"
Index: WAeUP_SRP/trunk/profiles/futminna/layouts/acco_hall.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/futminna/layouts/acco_hall.xml	(revision 3783)
+++ WAeUP_SRP/trunk/profiles/futminna/layouts/acco_hall.xml	(revision 3784)
@@ -229,13 +229,4 @@
   </row>
   <row>
-   <cell name="beds_for_pre"/>
-  </row>  
-  <row>
-   <cell name="beds_for_fresh"/>
-  </row>
-  <row>
-   <cell name="beds_for_final"/>
-  </row>
-  <row>
    <cell name="reserved_rooms"/>
   </row>
Index: WAeUP_SRP/trunk/profiles/futminna/vocabularies/pin_prefixes.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/futminna/vocabularies/pin_prefixes.xml	(revision 3783)
+++ WAeUP_SRP/trunk/profiles/futminna/vocabularies/pin_prefixes.xml	(revision 3784)
@@ -7,5 +7,5 @@
     <property name="acl_write_roles">Manager</property>
 
-    <item key="IPTP" msgid="">IPTP Application</item>
+    <item key="APP" msgid="">Application</item>
     <item key="CLR" msgid="">Clearance</item>
     <item key="HOS" msgid="">Hostel Booking</item>
Index: WAeUP_SRP/trunk/profiles/futminna/vocabularies/waeup_block_letters.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/futminna/vocabularies/waeup_block_letters.xml	(revision 3784)
+++ WAeUP_SRP/trunk/profiles/futminna/vocabularies/waeup_block_letters.xml	(revision 3784)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="vocabulary.xsl"?>
+<object name="waeup_bed_letters" meta_type="CPS Vocabulary">
+ <property name="title"></property>
+ <property name="title_msgid"></property>
+ <property name="description"></property>
+ <property name="acl_write_roles">Manager</property>
+ <item key="A" msgid="">Block A</item>
+ <item key="B" msgid="">Block B</item>
+ <item key="C" msgid="">Block C</item>
+ <item key="D" msgid="">Block D</item>
+ <item key="E" msgid="">Block E</item>
+ <item key="F" msgid="">Block F</item>
+ <item key="G" msgid="">Block G</item>
+ <item key="H" msgid="">Block H</item>
+ <item key="I" msgid="">Block I</item>
+ <item key="K" msgid="">Block K</item>
+ <item key="L" msgid="">Block L</item>
+ <item key="M" msgid="">Block M</item>
+ <item key="N" msgid="">Block N</item>
+ <item key="O" msgid="">Block O</item>
+ <item key="P" msgid="">Block P</item>
+ <item key="Q" msgid="">Block Q</item>
+</object>
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/getAccommodationInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/getAccommodationInfo.py	(revision 3784)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/getAccommodationInfo.py	(revision 3784)
@@ -0,0 +1,149 @@
+## Script (Python) "getAccommodationInfo"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=student_id=None
+##title=
+##
+# $Id: getAccommodationInfo.py 1726 2007-05-02 06:21:50Z henrik $
+"""
+return Info about the current Student
+"""
+import logging
+logger = logging.getLogger('Skins.getAccommodationInfo')
+import DateTime
+
+request = context.REQUEST
+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
+info = {}
+if student_id is None:
+    requested_id = context.getStudentId()
+    if requested_id and not context.isStaff() and member_id != requested_id:
+        logger.info('%s tried to access %s' % (member_id,requested_id))
+        return None
+    elif context.isStaff():
+        student_id = requested_id
+    else:
+        student_id = member_id
+student_record = context.students_catalog.getRecordByKey(student_id)
+if student_record is None:
+    logger.info('%s not found in students_catalog' % student_id)
+    return None
+
+info['error'] = None
+info['matric_no']=student_record.matric_no
+info['jamb_reg_no']=student_record.jamb_reg_no
+info['name']=student_record.name
+info['email']=student_record.email
+info['level']=student_record.level
+info['verdict']=getattr(student_record,'verdict','')
+review_state = info['review_state'] = student_record.review_state
+info['session'] = session = context.getSessionId()
+students_object = context.portal_url.getPortalObject().campus.students
+student = getattr(students_object, student_id)
+info['student_id'] = student_id
+info['student'] = student
+
+booking_allowed = False
+
+# customize from here
+
+ekehuan_certificates = ('BARTAPG',
+                        'BARTAPM',
+                        'BARTCER',
+                        'BARTFAA',
+                        'BARTFAP',
+                        'BARTSCP',
+                        'BARTTXT',
+                        'BARTMAS',
+                        'BARTTHR',
+                        )
+
+new_states = ('cleared_and_validated',
+              'school_fee_paid',
+              'courses_registered',
+              'courses_validated',
+              )
+
+new = student_record.entry_session == session[0]
+arrived = student_record.session == session[0]
+
+level = None
+end_level = None
+previous = None
+
+try:
+    level = int(student_record.level)
+except:
+    logger.info('%s has invalid level %s' % (student_id,student_record.level))
+try:
+    end_level = int(student_record.end_level)
+except:
+    logger.info('%s has invalid end_level %s' % (student_id,student_record.end_level))
+try:
+    previous = int(student_record.session) == int(session[0]) - 1
+except:
+    logger.info('%s has invalid session %s' % (student_id,student_record.session))
+
+if level is None or end_level is None or student_record.review_state == 'deactivated':
+    pass
+elif arrived:
+    if new:
+        booking_allowed = student_record.review_state in new_states
+    else:
+        booking_allowed = not (level % 100)
+elif previous:
+    booking_allowed = student_record.verdict in ('A','B',)
+
+info['booking_allowed'] = booking_allowed
+if not booking_allowed:
+    info['acco'] = None
+    info['student_status'] = ''
+    return info
+
+acco_id = 'accommodation_' + session[0]
+acco = getattr(student,acco_id,None)
+info['acco'] = acco
+info['acco_id'] = acco_id
+bt = 're'
+info['maintenance_paid'] = False
+if acco is not None:
+    info['acco_doc'] = acco.getContent()
+    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None)
+    info['maintenance_paid'] = info['acco_review_state'] == "maintenance_fee_paid"
+
+d = {}
+delta = 0
+if previous:
+    delta = 100
+if new:
+    bt = 'fr'
+elif level + delta < end_level:
+    bt = 're'
+else:
+    bt = 'fi'
+
+d['sex'] = 'male'
+if student_record.sex:
+    d['sex'] = 'female'
+if student_record.faculty in ('MED','DEN') and level > 400:
+    bt += "_med"
+elif student_record.course in ekehuan_certificates:
+    bt += "_ekenhuan"
+#elif student_record.course in pti_certificates:
+#    bt += "_pti"
+info['sex']=d['sex']
+d['bt'] = bt
+student_status = "%(sex)s_%(bt)s" % d
+info['student_status'] = student_status
+return info
+
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/getBedTypeNames.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/getBedTypeNames.py	(revision 3783)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/getBedTypeNames.py	(revision 3784)
@@ -10,5 +10,6 @@
 # $Id$
 
-type_suffixes = [('fr','New Student'),
+type_suffixes = [('all','Student'),
+                 ('fr','New Student'),
                  ('fi','Final Student'),
                  ('re','Returning Student'),
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_accommodation.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_accommodation.py	(revision 3784)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_accommodation.py	(revision 3784)
@@ -0,0 +1,149 @@
+## Script (Python) "reserve_accommodation.py"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=REQUEST
+# $Id: reserve_accommodation.py 3406 2008-04-02 07:16:08Z henrik $
+"""
+process the the accommodation reservation
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+import DateTime
+current = DateTime.DateTime()
+pr = context.portal_registration
+wftool = context.portal_workflow
+lt = context.portal_layouts
+info = context.getAccommodationInfo()
+
+import logging
+logger = logging.getLogger('Skins.reserve_accommodation')
+
+#if info is None:
+#    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
+
+if info is None:
+    member_id = str(context.portal_membership.getAuthenticatedMember())
+    logger.info('%s tried to reserve accommodation' % (member_id))
+    return context.REQUEST.RESPONSE.redirect("%s/srp_invalid_access" % context.portal_url())
+
+mode = 'create'
+if not info['booking_allowed']:
+    return context.REQUEST.RESPONSE.redirect("%s/no_booking_allowed" % info['student'].absolute_url())
+student = info['student']
+student_id = info['student_id']
+acco_id = info['acco_id']
+#session = info['session'][1]
+session = info['session'][0]
+
+validate = REQUEST.has_key("cpsdocument_create_button")
+if info.has_key('acco') and info['acco']:
+    validate = REQUEST.has_key("cpsdocument_edit_button")
+    if info['maintenance_paid']:
+        if not info['acco_doc'].acco_maint_fee:
+            d_update = {}
+            hall_info = context.waeup_tool.getHallInfo(info['acco_doc'].bed)
+            d_update['acco_maint_fee'] = hall_info.get('maintenance_fee')
+            wftool.doActionFor(info['acco'],'reserve_bed')
+            info['acco_doc'].edit(mapping=d_update)
+            wftool.doActionFor(info['acco'],'pay_maintenance_fee')
+        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
+    # elif info['online_payment']:
+    #     return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
+    #     # return context.REQUEST.RESPONSE.redirect("%s/pay_interswitch_acco?paytype=HOM" % info['student'].absolute_url())
+    else:
+        mode = 'edit'
+d = {}
+button = "Book"
+if mode == 'edit':
+    d['acco_res_date'] = info['acco_doc'].acco_res_date
+    d['acco_res_sc_pin'] = info['acco_doc'].acco_res_sc_pin
+    d['acco_maint_fee'] = info['acco_doc'].acco_maint_fee
+    d['student_status'] = info['acco_doc'].student_status
+    d['bed'] = info['acco_doc'].bed
+    d['session'] = info['acco_doc'].session
+    button = "Pay Maintainance Fee"
+res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
+                      schema_id= 'student_accommodation',
+                      context=context,
+                      mapping=validate and REQUEST,
+                      ob=d,
+                      layout_mode=mode,
+                      formaction = "reserve_accommodation",
+                      button = button
+                      )
+if psm == 'invalid':                      # or info['error'] is not None:
+    member_id = str(context.portal_membership.getAuthenticatedMember())
+    #logger.info('%s, %s' % (member_id,info['error'] ))
+    logger.info('%s entered invalid data' % (member_id))
+    if psm == 'invalid':
+        psm = "Please correct your input."
+    else:
+        psm = "Error in data, unable to reserve bed."
+    return context.accommodation_edit_form(rendered = res,
+                                 psm = psm,
+                                 #psm = "%s, %s" % (psm,ds),
+                                 mode = mode,
+                                 ds = ds,
+                                 )
+elif psm == '':
+    return context.accommodation_edit_form(rendered = res,
+                                 psm = None,
+                                 mode = mode,
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    if mode == 'create':
+        #set_trace()
+        pin = str(ds.get('acco_res_sc_pin'))
+        code,bed = context.portal_accommodation.searchAndReserveBed(student_id,
+                                                                    "%s" % (info['student_status']))
+        while True:
+            if code == 1:
+                break
+            if code == -1:
+                break
+                #return context.accommodation_edit_form(rendered = res,
+                #                        psm = "%s" % bed,
+                #                        mode = mode,
+                #                        ds = ds,
+                #                        )
+            elif code == -2:
+                return context.accommodation_edit_form(rendered = res,
+                                        psm = "No bed available. Your category is already fully booked.",
+                                        mode = mode,
+                                        ds = ds,
+                                        )
+            else: # unknown error
+                return context.accommodation_edit_form(rendered = res,
+                                        psm = "Unexpected Error!",
+                                        mode = mode,
+                                        ds = ds,
+                                        )
+        student.invokeFactory('StudentAccommodation',acco_id)
+        hall_info = context.waeup_tool.getHallInfo(bed)
+        ds.set('acco_maint_code', hall_info.get('maintenance_code'))
+        ds.set('acco_maint_fee', hall_info.get('maintenance_fee'))
+        ds.set('acco_res_date', current)
+        ds.set('bed', bed)
+        ds.set('session', session)
+        ds.set('student_status',info['student_status'])
+        acco = getattr(student,acco_id)
+        acco.getContent().edit(mapping=ds)
+        #wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
+        return context.REQUEST.RESPONSE.redirect("%s/reserve_accommodation" % student.absolute_url())
+#pin = str(ds.get('acco_main_sc_pin'))
+#pp = context.portal_pins
+#acco = getattr(student,acco_id)
+d = {}
+d['acco_maint_sc_pin'] = ds.get('acco_maint_sc_pin')
+d['acco_maint_date'] = current
+info['acco_doc'].edit(mapping=d)
+wftool.doActionFor(info['acco'],'pay_maintenance_fee')
+return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
+
Index: WAeUP_SRP/trunk/skins/waeup_futminna/getAccommodationInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_futminna/getAccommodationInfo.py	(revision 3784)
+++ WAeUP_SRP/trunk/skins/waeup_futminna/getAccommodationInfo.py	(revision 3784)
@@ -0,0 +1,123 @@
+## Script (Python) "getAccommodationInfo"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=student_id=None
+##title=
+##
+# $Id: getAccommodationInfo.py 1726 2007-05-02 06:21:50Z henrik $
+"""
+return Info about the current Student
+"""
+import logging
+logger = logging.getLogger('Skins.getAccommodationInfo')
+import DateTime
+
+request = context.REQUEST
+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
+info = {}
+if student_id is None:
+    requested_id = context.getStudentId()
+    if requested_id and not context.isStaff() and member_id != requested_id:
+        logger.info('%s tried to access %s' % (member_id,requested_id))
+        return None
+    elif context.isStaff():
+        student_id = requested_id
+    else:
+        student_id = member_id
+student_record = context.students_catalog.getRecordByKey(student_id)
+if student_record is None:
+    logger.info('%s not found in students_catalog' % student_id)
+    return None
+
+info['error'] = None
+info['matric_no']=student_record.matric_no
+info['jamb_reg_no']=student_record.jamb_reg_no
+info['name']=student_record.name
+info['email']=student_record.email
+info['level']=student_record.level
+info['verdict']=getattr(student_record,'verdict','')
+review_state = info['review_state'] = student_record.review_state
+info['session'] = session = context.getSessionId()
+students_object = context.portal_url.getPortalObject().campus.students
+student = getattr(students_object, student_id)
+info['student_id'] = student_id
+info['student'] = student
+
+booking_allowed = False
+
+# customize from here
+
+
+new_states = ('cleared_and_validated',
+              'school_fee_paid',
+              'courses_registered',
+              'courses_validated',
+              )
+
+new = student_record.entry_session == session[0]
+arrived = student_record.session == session[0]
+
+level = None
+end_level = None
+previous = None
+
+try:
+    level = int(student_record.level)
+except:
+    logger.info('%s has invalid level %s' % (student_id,student_record.level))
+try:
+    end_level = int(student_record.end_level)
+except:
+    logger.info('%s has invalid end_level %s' % (student_id,student_record.end_level))
+try:
+    previous = int(student_record.session) == int(session[0]) - 1
+except:
+    logger.info('%s has invalid session %s' % (student_id,student_record.session))
+
+if level is None or end_level is None or student_record.review_state == 'deactivated':
+    pass
+elif arrived:
+    if new:
+        booking_allowed = student_record.review_state in new_states
+    else:
+        booking_allowed = not (level % 100)
+elif previous:
+    booking_allowed = student_record.verdict in ('A','B',)
+
+info['booking_allowed'] = booking_allowed
+if not booking_allowed:
+    info['acco'] = None
+    info['student_status'] = ''
+    return info
+
+acco_id = 'accommodation_' + session[0]
+acco = getattr(student,acco_id,None)
+info['acco'] = acco
+info['acco_id'] = acco_id
+bt = 're'
+info['maintenance_paid'] = False
+if acco is not None:
+    info['acco_doc'] = acco.getContent()
+    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None)
+    info['maintenance_paid'] = info['acco_review_state'] == "maintenance_fee_paid"
+
+d = {}
+d['sex'] = 'male'
+if student_record.sex:
+    d['sex'] = 'female'
+info['sex']=d['sex']
+d['bt'] = 'all'
+student_status = "%(sex)s_%(bt)s" % d
+info['student_status'] = student_status
+return info
+
Index: WAeUP_SRP/trunk/skins/waeup_student/getAccommodationInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getAccommodationInfo.py	(revision 3783)
+++ 	(revision )
@@ -1,149 +1,0 @@
-## Script (Python) "getAccommodationInfo"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=student_id=None
-##title=
-##
-# $Id: getAccommodationInfo.py 1726 2007-05-02 06:21:50Z henrik $
-"""
-return Info about the current Student
-"""
-import logging
-logger = logging.getLogger('Skins.getAccommodationInfo')
-import DateTime
-
-request = context.REQUEST
-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
-info = {}
-if student_id is None:
-    requested_id = context.getStudentId()
-    if requested_id and not context.isStaff() and member_id != requested_id:
-        logger.info('%s tried to access %s' % (member_id,requested_id))
-        return None
-    elif context.isStaff():
-        student_id = requested_id
-    else:
-        student_id = member_id
-student_record = context.students_catalog.getRecordByKey(student_id)
-if student_record is None:
-    logger.info('%s not found in students_catalog' % student_id)
-    return None
-
-info['error'] = None
-info['matric_no']=student_record.matric_no
-info['jamb_reg_no']=student_record.jamb_reg_no
-info['name']=student_record.name
-info['email']=student_record.email
-info['level']=student_record.level
-info['verdict']=getattr(student_record,'verdict','')
-review_state = info['review_state'] = student_record.review_state
-info['session'] = session = context.getSessionId()
-students_object = context.portal_url.getPortalObject().campus.students
-student = getattr(students_object, student_id)
-info['student_id'] = student_id
-info['student'] = student
-
-booking_allowed = False
-
-# customize from here
-
-ekehuan_certificates = ('BARTAPG',
-                        'BARTAPM',
-                        'BARTCER',
-                        'BARTFAA',
-                        'BARTFAP',
-                        'BARTSCP',
-                        'BARTTXT',
-                        'BARTMAS',
-                        'BARTTHR',
-                        )
-
-new_states = ('cleared_and_validated',
-              'school_fee_paid',
-              'courses_registered',
-              'courses_validated',
-              )
-
-new = student_record.entry_session == session[0]
-arrived = student_record.session == session[0]
-
-level = None
-end_level = None
-previous = None
-
-try:
-    level = int(student_record.level)
-except:
-    logger.info('%s has invalid level %s' % (student_id,student_record.level))
-try:
-    end_level = int(student_record.end_level)
-except:
-    logger.info('%s has invalid end_level %s' % (student_id,student_record.end_level))
-try:
-    previous = int(student_record.session) == int(session[0]) - 1
-except:
-    logger.info('%s has invalid session %s' % (student_id,student_record.session))
-
-if level is None or end_level is None or student_record.review_state == 'deactivated':
-    pass
-elif arrived:
-    if new:
-        booking_allowed = student_record.review_state in new_states
-    else:
-        booking_allowed = not (level % 100)
-elif previous:
-    booking_allowed = student_record.verdict in ('A','B',)
-
-info['booking_allowed'] = booking_allowed
-if not booking_allowed:
-    info['acco'] = None
-    info['student_status'] = ''
-    return info
-
-acco_id = 'accommodation_' + session[0]
-acco = getattr(student,acco_id,None)
-info['acco'] = acco
-info['acco_id'] = acco_id
-bt = 're'
-info['maintenance_paid'] = False
-if acco is not None:
-    info['acco_doc'] = acco.getContent()
-    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None)
-    info['maintenance_paid'] = info['acco_review_state'] == "maintenance_fee_paid"
-
-d = {}
-delta = 0
-if previous:
-    delta = 100
-if new:
-    bt = 'fr'
-elif level + delta < end_level:
-    bt = 're'
-else:
-    bt = 'fi'
-
-d['sex'] = 'male'
-if student_record.sex:
-    d['sex'] = 'female'
-if student_record.faculty in ('MED','DEN') and level > 400:
-    bt += "_med"
-elif student_record.course in ekehuan_certificates:
-    bt += "_ekenhuan"
-#elif student_record.course in pti_certificates:
-#    bt += "_pti"
-info['sex']=d['sex']
-d['bt'] = bt
-student_status = "%(sex)s_%(bt)s" % d
-info['student_status'] = student_status
-return info
-
Index: WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 3783)
+++ 	(revision )
@@ -1,149 +1,0 @@
-## Script (Python) "reserve_accommodation.py"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=REQUEST
-# $Id$
-"""
-process the the accommodation reservation
-"""
-try:
-    from Products.zdb import set_trace
-except:
-    def set_trace():
-        pass
-import DateTime
-current = DateTime.DateTime()
-pr = context.portal_registration
-wftool = context.portal_workflow
-lt = context.portal_layouts
-info = context.getAccommodationInfo()
-
-import logging
-logger = logging.getLogger('Skins.reserve_accommodation')
-
-#if info is None:
-#    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
-
-if info is None:
-    member_id = str(context.portal_membership.getAuthenticatedMember())
-    logger.info('%s tried to reserve accommodation' % (member_id))
-    return context.REQUEST.RESPONSE.redirect("%s/srp_invalid_access" % context.portal_url())
-
-mode = 'create'
-if not info['booking_allowed']:
-    return context.REQUEST.RESPONSE.redirect("%s/no_booking_allowed" % info['student'].absolute_url())
-student = info['student']
-student_id = info['student_id']
-acco_id = info['acco_id']
-#session = info['session'][1]
-session = info['session'][0]
-
-validate = REQUEST.has_key("cpsdocument_create_button")
-if info.has_key('acco') and info['acco']:
-    validate = REQUEST.has_key("cpsdocument_edit_button")
-    if info['maintenance_paid']:
-        if not info['acco_doc'].acco_maint_fee:
-            d_update = {}
-            hall_info = context.waeup_tool.getHallInfo(info['acco_doc'].bed)
-            d_update['acco_maint_fee'] = hall_info.get('maintenance_fee')
-            wftool.doActionFor(info['acco'],'reserve_bed')
-            info['acco_doc'].edit(mapping=d_update)
-            wftool.doActionFor(info['acco'],'pay_maintenance_fee')
-        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
-    # elif info['online_payment']:
-    #     return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].absolute_url())
-    #     # return context.REQUEST.RESPONSE.redirect("%s/pay_interswitch_acco?paytype=HOM" % info['student'].absolute_url())
-    else:
-        mode = 'edit'
-d = {}
-button = "Book"
-if mode == 'edit':
-    d['acco_res_date'] = info['acco_doc'].acco_res_date
-    d['acco_res_sc_pin'] = info['acco_doc'].acco_res_sc_pin
-    d['acco_maint_fee'] = info['acco_doc'].acco_maint_fee
-    d['student_status'] = info['acco_doc'].student_status
-    d['bed'] = info['acco_doc'].bed
-    d['session'] = info['acco_doc'].session
-    button = "Pay Maintainance Fee"
-res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
-                      schema_id= 'student_accommodation',
-                      context=context,
-                      mapping=validate and REQUEST,
-                      ob=d,
-                      layout_mode=mode,
-                      formaction = "reserve_accommodation",
-                      button = button
-                      )
-if psm == 'invalid':                      # or info['error'] is not None:
-    member_id = str(context.portal_membership.getAuthenticatedMember())
-    #logger.info('%s, %s' % (member_id,info['error'] ))
-    logger.info('%s entered invalid data' % (member_id))
-    if psm == 'invalid':
-        psm = "Please correct your input."
-    else:
-        psm = "Error in data, unable to reserve bed."
-    return context.accommodation_edit_form(rendered = res,
-                                 psm = psm,
-                                 #psm = "%s, %s" % (psm,ds),
-                                 mode = mode,
-                                 ds = ds,
-                                 )
-elif psm == '':
-    return context.accommodation_edit_form(rendered = res,
-                                 psm = None,
-                                 mode = mode,
-                                 ds = ds,
-                                 )
-elif psm == 'valid':
-    if mode == 'create':
-        #set_trace()
-        pin = str(ds.get('acco_res_sc_pin'))
-        code,bed = context.portal_accommodation.searchAndReserveBed(student_id,
-                                                                    "%s" % (info['student_status']))
-        while True:
-            if code == 1:
-                break
-            if code == -1:
-                break
-                #return context.accommodation_edit_form(rendered = res,
-                #                        psm = "%s" % bed,
-                #                        mode = mode,
-                #                        ds = ds,
-                #                        )
-            elif code == -2:
-                return context.accommodation_edit_form(rendered = res,
-                                        psm = "No bed available. Your category is already fully booked.",
-                                        mode = mode,
-                                        ds = ds,
-                                        )
-            else: # unknown error
-                return context.accommodation_edit_form(rendered = res,
-                                        psm = "Unexpected Error!",
-                                        mode = mode,
-                                        ds = ds,
-                                        )
-        student.invokeFactory('StudentAccommodation',acco_id)
-        hall_info = context.waeup_tool.getHallInfo(bed)
-        ds.set('acco_maint_code', hall_info.get('maintenance_code'))
-        ds.set('acco_maint_fee', hall_info.get('maintenance_fee'))
-        ds.set('acco_res_date', current)
-        ds.set('bed', bed)
-        ds.set('session', session)
-        ds.set('student_status',info['student_status'])
-        acco = getattr(student,acco_id)
-        acco.getContent().edit(mapping=ds)
-        #wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
-        return context.REQUEST.RESPONSE.redirect("%s/reserve_accommodation" % student.absolute_url())
-#pin = str(ds.get('acco_main_sc_pin'))
-#pp = context.portal_pins
-#acco = getattr(student,acco_id)
-d = {}
-d['acco_maint_sc_pin'] = ds.get('acco_maint_sc_pin')
-d['acco_maint_date'] = current
-info['acco_doc'].edit(mapping=d)
-wftool.doActionFor(info['acco'],'pay_maintenance_fee')
-return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
-
