Index: WAeUP_SRP/trunk/skins/waeup_student/accommodation_pin_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/accommodation_pin_form.pt	(revision 652)
+++ WAeUP_SRP/trunk/skins/waeup_student/accommodation_pin_form.pt	(revision 652)
@@ -0,0 +1,30 @@
+<tal:block define="rendered_main options/rendered;
+                   portal_status_message options/psm;
+                   data_storage options/ds;
+                   jamb options/jamb/getContent|nothing;
+                   edition python:1;"
+                   >
+<metal:block define-macro="edit_form">
+  <metal:block use-macro="here/content_lib_master/macros/master">
+  <metal:block fill-slot="header"
+    tal:define="creation creation|nothing;
+                edition edition|nothing;
+                metadata metadata|nothing"
+                >
+    </metal:block>
+      <metal:block fill-slot="main">
+        <h3>Book Your Accommodation! </h3>
+        <br />
+        <div tal:replace="structure rendered_main" />
+          <p>Instructions :</p>
+          <ul>
+            <li>Buy a Hostel Application Scratch Card.</li> 
+            <li>Enter the PIN above.</li>
+            <li>Print the Hostel Allocation Slip.</li>
+          </ul>
+      </metal:block>
+      <metal:block fill-slot="sub">
+      </metal:block>
+    </metal:block>
+  </metal:block>
+</tal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/accommodation_slip.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/accommodation_slip.pt	(revision 652)
+++ WAeUP_SRP/trunk/skins/waeup_student/accommodation_slip.pt	(revision 652)
@@ -0,0 +1,29 @@
+<html metal:use-macro="here/content_lib_master/macros/master">
+  <metal:block fill-slot="head_slot">
+  </metal:block>
+
+  <metal:block fill-slot="css_slot">
+    <link rel="Stylesheet" type="text/css" href=""
+      tal:attributes="href string:${base_url}document.css" />
+  </metal:block>
+  
+  <metal:block fill-slot="header">
+  </metal:block>
+
+  <metal:block fill-slot="main"
+      tal:define="info context/getStudentInfo">
+    <h3>Hostal Reservation Acknowledge Slip</h3>
+    <br />
+    
+    <table width="" cellpadding="2" cellspacing="0" summary="Form layout"
+           tal:define="acco_doc nocall: info/acco_doc"
+           >
+      <tr><td>Reservation Date: </td><td><span tal:content="python:acco_doc.acco_res_date.aCommonZ()" /></td></tr>
+      <tr><td>Pin used: </td><td><span tal:content="acco_doc/acco_res_sc_pin" /></td></tr>
+      <tr><td>Bed </td><td><span tal:content="python:context.formatBed(acco_doc.bed)" /></td></tr>
+    </table>
+  </metal:block>
+  
+  <metal:block fill-slot="sub">
+  </metal:block>
+</html>
Index: WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 652)
+++ WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 652)
@@ -0,0 +1,72 @@
+##parameters=REQUEST
+# $Id: apply_admission.py 543 2006-09-24 07:44:32Z henrik $
+"""
+process the Application Form
+return html renderer + psm
+"""
+import DateTime
+current = DateTime.DateTime()
+pr = context.portal_registration
+
+info = context.getStudentInfo()
+validate = REQUEST.has_key("cpsdocument_create_button")
+
+lt = context.portal_layouts
+pr = context.portal_registration
+session = current.year()
+acco_id = 'Acco_%s' % session
+info = context.getStudentInfo()
+student = info['student']
+if info['acco']:
+    return context.REQUEST.RESPONSE.redirect("%s" % info['acco'].absolute_url())
+res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
+                      schema_id= 'student_accommodation_fe',
+                      context=context,
+                      mapping=validate and REQUEST,
+                      ob={},
+                      layout_mode='create',
+                      formaction = "reserve_accommodation",
+                      button = "book Bed",
+                      )
+if psm == 'invalid':
+    return context.accommodation_pin_form(rendered = res,
+                                 #psm = "Please correct your input.",
+                                 psm = "%s, %s" % (psm,ds),
+                                 firstlayout = True,
+                                 lastlayout = True,
+                                 ds = ds,
+                                 )
+elif psm == '':
+    return context.accommodation_pin_form(rendered = res,
+                                 psm = None,
+                                 firstlayout = True,
+                                 lastlayout = True,
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    s_id = ds.get('s_id')
+    pin = str(ds.get('acco_res_ac_pin'))
+    
+    pa = context.portal_accommodation
+    code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
+    if code < 0:
+        return context.accommodation_pin_form(rendered = res,
+                                 psm = bed,
+                                 firstlayout = True,
+                                 lastlayout = True,
+                                 ds = ds,
+                                 )
+student.invokeFactory('StudentAccommodation',acco_id)
+acco = getattr(student,acco_id)
+ds.set('acco_res_date', current)
+ds.set('bed', bed)
+ds.set('session', session)
+acco.getContent().edit(mapping=ds)
+return context.REQUEST.RESPONSE.redirect("%s/accommodation_slip" % student.absolute_url())
+##return context.accommodation_pin_form(rendered = res,
+##                                 psm = "successfully reserved bed %s" % bed,
+##                                 firstlayout = True,
+##                                 lastlayout = True,
+##                                 ds = ds,
+##                                 )
+
