Index: /WAeUP_SRP/trunk/doc/srp_documentation.mm
===================================================================
--- /WAeUP_SRP/trunk/doc/srp_documentation.mm	(revision 1411)
+++ /WAeUP_SRP/trunk/doc/srp_documentation.mm	(revision 1412)
@@ -34,7 +34,11 @@
 <node CREATED="1171014630747" ID="Freemind_Link_21788009" MODIFIED="1171014635284" TEXT="Imports"/>
 </node>
-<node CREATED="1170082138244" ID="Freemind_Link_1354366927" MODIFIED="1170082146391" TEXT="Students">
+<node CREATED="1170082138244" FOLDED="true" ID="Freemind_Link_1354366927" MODIFIED="1170082146391" TEXT="Students">
 <node CREATED="1170082147831" ID="Freemind_Link_115332414" MODIFIED="1170082160733" TEXT="n * Student">
-<node CREATED="1170082164451" FOLDED="true" ID="Freemind_Link_1627718074" MODIFIED="1170082180091" TEXT="Application">
+<node CREATED="1171114205479" ID="Freemind_Link_1051911128" LINK="../profiles/default/types/Student.xml" MODIFIED="1171353141707" TEXT="Type: Student"/>
+<node CREATED="1171124926993" ID="Freemind_Link_1838352082" LINK="../profiles/default/schemas/student.xml" MODIFIED="1171353152905" TEXT="Schema: student"/>
+<node CREATED="1171124982312" ID="Freemind_Link_1037588671" LINK="../profiles/default/layouts/student.xml" MODIFIED="1171353165422" TEXT="Layout: student"/>
+<node CREATED="1171353188624" ID="Freemind_Link_1032185087" LINK="../profiles/default/workflows/waeup_student_wf/definition.xml" MODIFIED="1171353319663" TEXT="Workflow: waeup_student_wf"/>
+<node CREATED="1170082164451" ID="Freemind_Link_1627718074" MODIFIED="1170082180091" TEXT="Application">
 <node CREATED="1170083733194" ID="Freemind_Link_1398132513" MODIFIED="1170862024807" TEXT="Id: application"/>
 <node CREATED="1170083603042" ID="Freemind_Link_4951906" LINK="../profiles/default/types/StudentApplication.xml" MODIFIED="1171009517689" TEXT="Type: StudentApplication"/>
@@ -70,6 +74,19 @@
 <node CREATED="1171014603296" ID="Freemind_Link_592162547" MODIFIED="1171014611096" TEXT="Imports"/>
 </node>
-<node CREATED="1170082502675" FOLDED="true" ID="Freemind_Link_1051871348" MODIFIED="1170082511430" TEXT="Accommodation">
-<node CREATED="1170082513362" ID="Freemind_Link_579142716" MODIFIED="1170082530016" TEXT="n * Hall"/>
+<node CREATED="1170082502675" ID="Freemind_Link_1051871348" MODIFIED="1170082511430" TEXT="Accommodation">
+<node CREATED="1171114205479" ID="Freemind_Link_685193459" LINK="../profiles/default/types/AccoFolder.xml" MODIFIED="1171360542032" TEXT="Type: AccoFolder"/>
+<node CREATED="1170082513362" ID="Freemind_Link_579142716" MODIFIED="1170082530016" TEXT="n * Hall">
+<node CREATED="1171114205479" ID="Freemind_Link_913388948" LINK="../profiles/default/types/AccoHall.xml" MODIFIED="1171360892599" TEXT="Type: AccoHall"/>
+<node CREATED="1171124926993" ID="Freemind_Link_108322260" LINK="../profiles/default/schemas/acco_hall.xml" MODIFIED="1171361085015" TEXT="Schema: acco_hall"/>
+<node CREATED="1171124982312" ID="Freemind_Link_378355401" LINK="../profiles/default/layouts/acco_hall.xml" MODIFIED="1171361118597" TEXT="Layout: acco_hall"/>
+<node CREATED="1171362437684" ID="Freemind_Link_1642729597" MODIFIED="1171362486789" TEXT="UserInterface">
+<node CREATED="1171362489012" ID="Freemind_Link_550352037" MODIFIED="1171362509942" TEXT="book_reserved_bed">
+<node CREATED="1171362515581" ID="Freemind_Link_213666573" LINK="../skins/waeup_accommodation/book_reserved_bed.py" MODIFIED="1171362598179" TEXT="Script: book_reserved_bed"/>
+<node CREATED="1171362924343" ID="Freemind_Link_1340566317" LINK="../skins/waeup_accommodation/book_reserved_bed_form.pt" MODIFIED="1171363012800" TEXT="PT: book_reserved_bed_form"/>
+<node CREATED="1171124926993" ID="Freemind_Link_320666824" LINK="../profiles/default/schemas/acco_bed_booking.xml" MODIFIED="1171362834619" TEXT="Schema: acco_bed_booking"/>
+<node CREATED="1171124982312" ID="Freemind_Link_1520138434" LINK="../profiles/default/layouts/acco_bed_booking.xml" MODIFIED="1171362901153" TEXT="Layout: acco_bed_booking"/>
+</node>
+</node>
+</node>
 </node>
 <node CREATED="1170082542534" ID="Freemind_Link_243354429" MODIFIED="1170082550976" TEXT="Pins">
Index: /WAeUP_SRP/trunk/profiles/default/layouts/acco_bed_booking.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/acco_bed_booking.xml	(revision 1411)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/acco_bed_booking.xml	(revision 1412)
@@ -1,18 +1,19 @@
 <?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="layout.xsl"?>
 <object name="acco_bed_reservation" meta_type="CPS Layout">
  <property name="layout_create_method"></property>
  <property name="layout_edit_method"></property>
  <property name="layout_view_method"></property>
- <property name="style_prefix">layout_wo_object</property>
+ <property name="style_prefix">layout_waeup_</property>
  <property name="flexible_widgets"/>
  <property name="validate_values_expr"></property>
- <widget name="bed" meta_type="Select Widget">
-  <property name="title">Bed</property>
+ <widget name="bed_letter" meta_type="Select Widget">
+  <property name="title">Bed Letter</property>
   <property name="fields">
-   <element value="bed"/>
+   <element value="bed_letter"/>
   </property>
   <property name="is_required">True</property>
-  <property name="label">Bed</property>
-  <property name="label_edit">Bed</property>
+  <property name="label">Bed Letter</property>
+  <property name="label_edit">Bed Letter</property>
   <property name="readonly_layout_modes"/>
   <property name="hidden_layout_modes"/>
@@ -49,8 +50,8 @@
  <table>
   <row>
-   <cell name="block_floor_room"/>
+   <cell name="block_room"/>
   </row>
   <row>
-   <cell name="bed"/>
+   <cell name="bed_letter"/>
   </row>
   <row>
Index: /WAeUP_SRP/trunk/profiles/default/layouts/acco_hall.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/acco_hall.xml	(revision 1411)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/acco_hall.xml	(revision 1412)
@@ -1,4 +1,5 @@
 <?xml version="1.0"?>
-<object name="accommodation" meta_type="CPS Layout">
+<?xml-stylesheet type="text/xsl" href="layout.xsl"?>
+<object name="acco_hall" meta_type="CPS Layout">
  <property name="layout_create_method"></property>
  <property name="layout_edit_method"></property>
Index: /WAeUP_SRP/trunk/profiles/default/layouts/layout.xsl
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/layout.xsl	(revision 1411)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/layout.xsl	(revision 1412)
@@ -13,5 +13,5 @@
       <body>
         <xsl:for-each select="object">
-          <h1><xsl:value-of select="@name"/></h1>
+          <h1>Layout: <xsl:value-of select="@name"/></h1>
         </xsl:for-each>
         <h1>Layout</h1>
@@ -39,4 +39,8 @@
         <h1>Properties</h1>
         <table>
+          <tr>
+            <th>Id</th>
+            <th>Text</th>
+          </tr>
           <xsl:for-each select="object/property">
             <xsl:variable name="color">
@@ -61,24 +65,17 @@
         </table>
         <h1>Widgets</h1>
-        <table>
-          <xsl:for-each select="object/widget">
-            <xsl:variable name="color">
-              <xsl:choose>
-                <xsl:when test="position() mod 2 = 0">
-                  <xsl:text>#ffffff</xsl:text>
-                </xsl:when>
-                <xsl:otherwise>
-                  <xsl:text>#eeeeee</xsl:text>
-                </xsl:otherwise>
-              </xsl:choose>
-            </xsl:variable>
-            <tr style="background-color:{$color}">
-              <th>
-                <xsl:value-of select="@name"/>
-              </th>
-              <td colspan="2">
-                <xsl:value-of select="@meta_type"/>
-              </td>
-            </tr>
+        <xsl:for-each select="object/widget">
+          <xsl:variable name="color">
+            <xsl:choose>
+              <xsl:when test="position() mod 2 = 0">
+                <xsl:text>#ffffff</xsl:text>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:text>#eeeeee</xsl:text>
+              </xsl:otherwise>
+            </xsl:choose>
+          </xsl:variable>
+          <h3><xsl:value-of select="@name"/> Meta Type: <xsl:value-of select="@meta_type"/></h3>
+          <table>
             <tr style="background-color:{$color}">
               <th colspan="3">
@@ -101,6 +98,6 @@
               </tr>
             </xsl:for-each>
-          </xsl:for-each>
-        </table>
+          </table>
+        </xsl:for-each>
       </body>
     </html>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml	(revision 1411)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml	(revision 1412)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
 <?xml-stylesheet type="text/xsl" href="schema.xsl"?>
-<object name="accommodation" meta_type="CPS Schema">
+<object name="acco_hall" meta_type="CPS Schema">
   <field name="beds_for_final" meta_type="CPS String List Field"/>
   <field name="beds_for_fresh" meta_type="CPS String List Field"/>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/schema.xsl
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/schema.xsl	(revision 1411)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/schema.xsl	(revision 1412)
@@ -14,9 +14,14 @@
         <xsl:for-each select="object">
           <h2>
-            <xsl:value-of select="@name"/>
+            Schema: <xsl:value-of select="@name"/>
           </h2> 
         </xsl:for-each>
         <h1>Fields</h1>
         <table>
+          <tr>
+            <th>Id</th>
+            <th>Type</th>
+            <th>default</th>
+          </tr>
           <xsl:for-each select="object/field">
             <xsl:sort select="@name"
Index: /WAeUP_SRP/trunk/profiles/default/types/AccoFolder.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/types/AccoFolder.xml	(revision 1411)
+++ /WAeUP_SRP/trunk/profiles/default/types/AccoFolder.xml	(revision 1412)
@@ -1,3 +1,4 @@
 <?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="types.xsl"?>
 <object name="AccoFolder" meta_type="CPS Flexible Type Information"
    xmlns:i18n="http://xml.zope.org/namespaces/i18n">
@@ -12,5 +13,5 @@
  <property name="filter_content_types">True</property>
  <property name="allowed_content_types">
-  <element value="Accommodation"/>
+  <element value="AccoHall"/>
  </property>
  <property name="allow_discussion">False</property>
@@ -19,10 +20,7 @@
  <property name="cps_display_as_document_in_listing">True</property>
  <property name="schemas">
-  <element value="metadata"/>
-  <element value="common"/>
  </property>
  <property name="layouts"/>
  <property name="layout_clusters">
-  <element value="metadata:metadata"/>
  </property>
  <property name="flexible_layouts"/>
Index: /WAeUP_SRP/trunk/profiles/default/types/AccoHall.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/types/AccoHall.xml	(revision 1411)
+++ /WAeUP_SRP/trunk/profiles/default/types/AccoHall.xml	(revision 1412)
@@ -1,3 +1,4 @@
 <?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="types.xsl"?>
 <object name="AccoHall" meta_type="CPS Flexible Type Information"
    xmlns:i18n="http://xml.zope.org/namespaces/i18n">
Index: /WAeUP_SRP/trunk/profiles/default/types/Student.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/types/Student.xml	(revision 1411)
+++ /WAeUP_SRP/trunk/profiles/default/types/Student.xml	(revision 1412)
@@ -1,3 +1,4 @@
 <?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="types.xsl"?>
 <object name="Student" meta_type="CPS Flexible Type Information"
    xmlns:i18n="http://xml.zope.org/namespaces/i18n">
Index: /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 1411)
+++ /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 1412)
@@ -1,3 +1,4 @@
 <?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="../definition.xsl"?>
 <cps-workflow workflow_id="waeup_student_wf"
               title="CPS Workflow Definition"
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py	(revision 1411)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py	(revision 1412)
@@ -16,7 +16,8 @@
 
 mode = 'create'
-validate = REQUEST.has_key("cpsdocument_edit_button")
+validate = REQUEST.has_key("cpsdocument_edit_button") and\
+           REQUEST.get("cpsdocument_edit_button").startswith('reserve')
 d = {}
-res,psm,ds = lt.renderLayout(layout_id= 'acco_bed_booking',
+rendered,psm,ds = lt.renderLayout(layout_id= 'acco_bed_booking',
                       schema_id= 'acco_bed_booking',
                       context=context,
@@ -28,5 +29,5 @@
 if psm == 'invalid':
     psm = "Please correct your input."
-    return context.book_reserved_bed_form(rendered = res,
+    return context.book_reserved_bed_form(rendered = rendered,
                                  psm = psm,
                                  #psm = "%s, %s" % (psm,ds),
@@ -37,5 +38,5 @@
                                  )
 elif psm == '':
-    return context.book_reserved_bed_form(rendered = res,
+    return context.book_reserved_bed_form(rendered = rendered,
                                  psm = psm,
                                  mode = mode,
@@ -46,4 +47,5 @@
 elif psm == 'valid':
     pass
+#from Products.zdb import set_trace;set_trace()
 hall_id = context.getId()
 doc = context.getContent()
@@ -61,4 +63,8 @@
         break
     bed_brain = res[0]
+    already = acco_cat(student=sid) 
+    if already:
+        psm = "Student %s already reserved bed %s" % (sid, already[0].bed)
+        break
     if not bed_brain.bed_type.endswith("reserved"):
         psm = "Not a reserved bed %s" % bid
@@ -72,5 +78,5 @@
     break
 if psm != '':
-    return context.book_reserved_bed_form(rendered = res,
+    return context.book_reserved_bed_form(rendered = rendered,
                                  psm = psm,
                                  mode = mode,
@@ -80,10 +86,10 @@
                                  )
 acco_cat.modifyRecord(bed = bid, student = sid)
-logger.info('"%s","booked reserved bed %s for","%s"' % (member,bed,sid))
-return context.book_reserved_bed_form(rendered = res,
+logger.info('"%s","booked reserved bed %s for","%s"' % (member,bid,sid))
+return context.book_reserved_bed_form(rendered = "",
                                  psm = "Bed reserved for %s %s" % (sid,student.name),
                                  mode = mode,
                                  formaction = "book_reserved_bed",
-                                 button = "reserve bed",
+                                 button = "next reservation",
                                  ds = ds,
                                  )
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_accommodation.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_accommodation.py	(revision 1412)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_accommodation.py	(revision 1412)
@@ -0,0 +1,116 @@
+##parameters=REQUEST
+# $Id$
+"""
+process the the accommodation reservation
+"""
+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('Student.Accommodation.Reserve')
+
+#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']
+acco_id = info['acco_id']
+session = acco_id[-4:]
+validate = REQUEST.has_key("cpsdocument_create_button")
+if info.has_key('acco') and info['acco']:
+    validate = REQUEST.has_key("cpsdocument_edit_button")
+    if info['acco_review_state'] == "maintenance_fee_paid":
+        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].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['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'] ))
+    if psm == 'invalid':
+        psm = "Please correct your input."
+    else:
+        psm = "Error in data, unable to reserve bed."
+    return context.accommodation_pin_edit_form(rendered = res,
+                                 psm = psm,
+                                 #psm = "%s, %s" % (psm,ds),
+                                 mode = mode,
+                                 ds = ds,
+                                 )
+elif psm == '':
+    return context.accommodation_pin_edit_form(rendered = res,
+                                 psm = None,
+                                 mode = mode,
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    s_id = ds.get('s_id')
+    if mode == 'create':
+        pin = str(ds.get('acco_res_sc_pin'))
+        pa = context.portal_accommodation
+        already = pa(student=s_id)
+        if not already:
+            code,bed = pa.searchAndReserveBed(s_id,"%s" % (info['student_status']))
+            #code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
+            if code == -1:
+                return context.accommodation_pin_edit_form(rendered = res,
+                                     psm = "%s" % bed,
+                                     mode = mode,
+                                     ds = ds,
+                                     )
+            elif code == -2:
+                return context.accommodation_pin_edit_form(rendered = res,
+                                     psm = "No bed available. Your category is already fully booked.",
+                                     mode = mode,
+                                     ds = ds,
+                                     )
+        else:
+            bed = already[0].bed 
+        student.invokeFactory('StudentAccommodation',acco_id)
+        acco = getattr(student,acco_id)
+        acco_info = context.waeup_tool.getAccommodationInfo(bed)
+        ds.set('acco_maint_code', acco_info.get('maintenance_code'))
+        ds.set('acco_maint_fee', acco_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.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)
+ds.set('acco_maint_date', current)
+acco.getContent().edit(mapping=ds)
+wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
+return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
+
Index: eUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 1411)
+++ 	(revision )
@@ -1,112 +1,0 @@
-##parameters=REQUEST
-# $Id$
-"""
-process the the accommodation reservation
-"""
-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('Student.Accommodation.Reserve')
-
-#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']
-acco_id = info['acco_id']
-session = acco_id[-4:]
-validate = REQUEST.has_key("cpsdocument_create_button")
-if info.has_key('acco') and info['acco']:
-    validate = REQUEST.has_key("cpsdocument_edit_button")
-    if info['acco_review_state'] == "maintenance_fee_paid":
-        return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % info['acco'].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['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'] ))
-    if psm == 'invalid':
-        psm = "Please correct your input."
-    else:
-        psm = "Error in data, unable to reserve bed."
-    return context.accommodation_pin_edit_form(rendered = res,
-                                 psm = psm,
-                                 #psm = "%s, %s" % (psm,ds),
-                                 mode = mode,
-                                 ds = ds,
-                                 )
-elif psm == '':
-    return context.accommodation_pin_edit_form(rendered = res,
-                                 psm = None,
-                                 mode = mode,
-                                 ds = ds,
-                                 )
-elif psm == 'valid':
-    s_id = ds.get('s_id')
-    if mode == 'create':
-        pin = str(ds.get('acco_res_sc_pin'))
-        pa = context.portal_accommodation
-        code,bed = pa.searchAndReserveBed(s_id,"%s" % (info['student_status']))
-        #code,bed = pa.searchAndReserveBed(s_id,"%s_%s" % (info['sex'],ds.get('student_status')))
-        if code == -1:
-            return context.accommodation_pin_edit_form(rendered = res,
-                                 psm = "%s" % bed,
-                                 mode = mode,
-                                 ds = ds,
-                                 )
-        elif code == -2:
-            return context.accommodation_pin_edit_form(rendered = res,
-                                 psm = "No bed available. Your category is already fully booked.",
-                                 mode = mode,
-                                 ds = ds,
-                                 )
-        student.invokeFactory('StudentAccommodation',acco_id)
-        acco = getattr(student,acco_id)
-        acco_info = context.waeup_tool.getAccommodationInfo(bed)
-        ds.set('acco_maint_code', acco_info.get('maintenance_code'))
-        ds.set('acco_maint_fee', acco_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.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)
-ds.set('acco_maint_date', current)
-acco.getContent().edit(mapping=ds)
-wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
-return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
-
