Index: /WAeUP_SRP/trunk/Accommodation.py
===================================================================
--- /WAeUP_SRP/trunk/Accommodation.py	(revision 1392)
+++ /WAeUP_SRP/trunk/Accommodation.py	(revision 1393)
@@ -114,9 +114,9 @@
             return self.title
         return heading
-
-###)
+    ###)
 
 InitializeClass(AccoHall)
 
+    
 def addAccoHall(container, id, REQUEST=None, **kw):
     """Add a AccoHall."""
Index: /WAeUP_SRP/trunk/Students.py
===================================================================
--- /WAeUP_SRP/trunk/Students.py	(revision 1392)
+++ /WAeUP_SRP/trunk/Students.py	(revision 1393)
@@ -1178,5 +1178,5 @@
                 table.addRecord(**result)
             except ValueError:
-                import pdb;pdb.set_trace()
+                #import pdb;pdb.set_trace()
                 result['Error'] = "Duplicate"
                 no_import.append( format_error % result)
@@ -1210,4 +1210,6 @@
             open("%s/import/%sno_courses%s.csv" % (i_home,name,current),"a").write(
                                     '\n'.join(no_course_list))
+        em = '%d transactions commited total %s\n courses not found %s' % (tr_count,total,course_count)
+        logger.info(em)
         return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     ###)
Index: /WAeUP_SRP/trunk/Widgets.py
===================================================================
--- /WAeUP_SRP/trunk/Widgets.py	(revision 1392)
+++ /WAeUP_SRP/trunk/Widgets.py	(revision 1393)
@@ -203,6 +203,4 @@
 
 widgetRegistry.register(WAeUPReservedRoomsWidget)
-
-
 ###)
 
@@ -463,4 +461,41 @@
 
 widgetRegistry.register(MatricNoWidget)
+###)
+
+class StudentIdWidget(CPSStringWidget): ###(
+    """ StudentId Widget"""
+    meta_type = "StudentId Widget"
+    def validate(self, datastructure, **kw):
+        """Validate datastructure and update datamodel."""
+        valid = CPSStringWidget.validate(self, datastructure, **kw)
+        logger = logging.getLogger('StudentId.Validate')
+        #import pdb;pdb.set_trace()
+        s_cat = self.students_catalog
+        err = 0
+        widget_id = self.getWidgetId()
+        value = datastructure[widget_id]
+        if not valid or not value:
+            err = 'Invalid StudentId String %s.' % value
+            logger.info('"%s","invalid StudentId String"' % value)
+            datastructure['student'] = res
+        else:
+            value = value.upper()
+            res = s_cat(id = value)
+            if not res:
+                logger.info('"%s","StudentId not found."' % value)
+                err = 'No Student with StudentId %s.' % (value)
+                datastructure['student'] = None
+            else:
+                datastructure['student'] = res[0]
+        if err:
+            datastructure.setError(widget_id, err)
+        else:
+            datamodel = datastructure.getDataModel()
+            datamodel[self.fields[0]] = value
+        return not err
+
+InitializeClass(StudentIdWidget)
+
+widgetRegistry.register(StudentIdWidget)
 ###)
 
Index: /WAeUP_SRP/trunk/profiles/default/layouts.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 1392)
+++ /WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 1393)
@@ -3,4 +3,5 @@
  <property name="title"></property>
  <object name="acco_hall" meta_type="CPS Layout"/>
+ <object name="acco_bed_booking" meta_type="CPS Layout"/>
  <object name="academics_search" meta_type="CPS Layout"/>
  <object name="certificate" meta_type="CPS Layout"/>
Index: /WAeUP_SRP/trunk/profiles/default/layouts/acco_bed_booking.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/acco_bed_booking.xml	(revision 1393)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/acco_bed_booking.xml	(revision 1393)
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<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="flexible_widgets"/>
+ <property name="validate_values_expr"></property>
+ <widget name="bed" meta_type="Select Widget">
+  <property name="title">Bed</property>
+  <property name="fields">
+   <element value="bed"/>
+  </property>
+  <property name="is_required">True</property>
+  <property name="label">Bed</property>
+  <property name="label_edit">Bed</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="vocabulary">acco_hall_beds</property>
+ </widget>
+ <widget name="block_room" meta_type="Select Widget">
+  <property name="title">Block / Room</property>
+  <property name="fields">
+   <element value="block_room"/>
+  </property>
+  <property name="is_required">True</property>
+  <property name="label">Block / Floor / Room</property>
+  <property name="label_edit">Block / Room</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="vocabulary">acco_hall_reserved_rooms</property>
+ </widget>
+ <widget name="student_id" meta_type="StudentId Widget">
+  <property name="title">Student Id</property>
+  <property name="fields">
+   <element value="student_id"/>
+  </property>
+  <property name="is_required">True</property>
+  <property name="label">Student Id</property>
+  <property name="label_edit">Student Id</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes"/>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="display_width">7</property>
+  <property name="size_max">7</property>
+ </widget>
+ <table>
+  <row>
+   <cell name="block_floor_room"/>
+  </row>
+  <row>
+   <cell name="bed"/>
+  </row>
+  <row>
+   <cell name="student_id"/>
+  </row>
+ </table>
+</object>
Index: /WAeUP_SRP/trunk/profiles/default/schemas.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas.xml	(revision 1392)
+++ /WAeUP_SRP/trunk/profiles/default/schemas.xml	(revision 1393)
@@ -5,4 +5,5 @@
  <object name="academics_search" meta_type="CPS Schema"/>
  <object name="acco_hall" meta_type="CPS Schema"/>
+ <object name="acco_bed_booking" meta_type="CPS Schema"/>
  <object name="certificate" meta_type="CPS Schema"/>
  <object name="certificate_course" meta_type="CPS Schema"/>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/acco_bed_booking.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/acco_bed_booking.xml	(revision 1393)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/acco_bed_booking.xml	(revision 1393)
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<object name="acco_bed_booking" meta_type="CPS Schema">
+ <field name="bed_letter" meta_type="CPS String Field"/>
+ <field name="block_room" meta_type="CPS String Field"/>
+ <field name="student_id" meta_type="CPS String Field"/>
+</object>
Index: /WAeUP_SRP/trunk/profiles/default/vocabularies.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/vocabularies.xml	(revision 1392)
+++ /WAeUP_SRP/trunk/profiles/default/vocabularies.xml	(revision 1393)
@@ -2,4 +2,6 @@
 <object name="portal_vocabularies" meta_type="CPS Vocabularies Tool">
  <property name="title"></property>
+ <object name="acco_hall_beds" meta_type="CPS Method Vocabulary"/>
+ <object name="acco_hall_reserved_rooms" meta_type="CPS Method Vocabulary"/>
  <object name="courselevel" meta_type="CPS Vocabulary"/>
  <object name="exam_subjects" meta_type="CPS Vocabulary"/>
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py	(revision 1393)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py	(revision 1393)
@@ -0,0 +1,90 @@
+##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
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+acco_cat = context.portal_accommodation
+import logging
+logger = logging.getLogger('Accommodation')
+
+mode = 'create'
+validate = REQUEST.has_key("cpsdocument_edit_button")
+d = {}
+res,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.book_reserved_bed_form(rendered = res,
+                                 psm = psm,
+                                 #psm = "%s, %s" % (psm,ds),
+                                 mode = mode,
+                                 formaction = "book_reserved_bed",
+                                 button = "reserve bed",
+                                 ds = ds,
+                                 )
+elif psm == '':
+    return context.book_reserved_bed_form(rendered = res,
+                                 psm = psm,
+                                 mode = mode,
+                                 formaction = "book_reserved_bed",
+                                 button = "reserve bed",
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    pass
+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 = bed)
+psm = ''
+while True:
+    if not res:
+        psm = "No bed with id %s" % bid
+        break
+    bed_brain = res[0]
+    if not bed_brain.bed_type.endswith("reserved"):
+        psm = "Not a reserved bed %s" % bid
+        break
+    if bed_brain.student:
+        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
+    break
+if psm != '':
+    return context.book_reserved_bed_form(rendered = res,
+                                 psm = psm,
+                                 mode = mode,
+                                 ds = ds,
+                                 formaction = "book_reserved_bed",
+                                 button = "reserve bed",
+                                 )
+acco_cat.modifyRecord(bed = bed, student = sid)
+logger.info('"%s","booked reserved bed %s for","%s"' % (member,bed,sid))
+return context.book_reserved_bed_form(rendered = res,
+                                 psm = "Bed reserved for %s %s" % (sid,student.name),
+                                 mode = mode,
+                                 formaction = "book_reserved_bed",
+                                 button = "reserve bed",
+                                 ds = ds,
+                                 )
+
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed_form.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed_form.pt	(revision 1393)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed_form.pt	(revision 1393)
@@ -0,0 +1,39 @@
+<tal:block define="rendered_main options/rendered;
+           portal_status_message options/psm;
+           data_storage options/ds;
+           mode options/mode;
+           formaction options/formaction;
+           matric_no options/matric_no|nothing;
+           name options/name|nothing;
+           creation creation|nothing;"
+           >
+  <metal:block define-macro="edit_form">
+    <metal:block use-macro="here/content_lib_master/macros/master">
+      <metal:block fill-slot="header">
+      </metal:block>
+      <metal:block fill-slot="main">
+        <form action="" id="editForm" method="post" 
+              enctype="multipart/form-data" class="workflow"
+              tal:attributes="action options/formaction"
+              >
+          <div tal:replace="structure rendered_main" />
+          <br />
+          <input type="submit" class="standalone" name="cpsdocument_edit_button"
+                 value="Save" 
+                 id="cpsdocument_edit_button"
+                 tal:attributes="value options/button"
+                 tal:condition="not:creation" />
+          <input type="submit" 
+                 class="standalone" 
+                 name="cpsdocument_create_button"
+                 value="apply"
+                 tal:attributes="value options/button"
+                 tal:condition="creation" />
+          
+        </form>
+      </metal:block>
+      <metal:block fill-slot="sub">
+      </metal:block>
+    </metal:block>
+  </metal:block>
+</tal:block>
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/getAccoHallBeds.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/getAccoHallBeds.py	(revision 1393)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/getAccoHallBeds.py	(revision 1393)
@@ -0,0 +1,10 @@
+##parameters=key=None 
+# $Id$
+"""
+Return the bedletters as an vocabulary
+
+"""
+doc = context.getContent()
+if key is None:
+    return [(l,l) for l in 'ABCDEFGH'[:doc.beds_per_room]]
+return key
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/reservedRoomsVoc.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/reservedRoomsVoc.py	(revision 1393)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/reservedRoomsVoc.py	(revision 1393)
@@ -0,0 +1,15 @@
+##parameters=key=None 
+# $Id$
+"""
+Return the reservedrooms as an vocabulary
+
+"""
+doc = context.getContent()
+voc = [("_".join((r.split('/')[0],r.split('/')[1])),r) 
+                      for r in doc.reserved_rooms.split(',') if r]
+#from Products.zdb import set_trace;set_trace()
+if not key:
+    return voc
+for k,v in voc:
+    if k == key:
+        return v
Index: /WAeUP_SRP/trunk/skins/waeup_default/layout_wo_object_create.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/layout_wo_object_create.pt	(revision 1393)
+++ /WAeUP_SRP/trunk/skins/waeup_default/layout_wo_object_create.pt	(revision 1393)
@@ -0,0 +1,91 @@
+<tal:block define="global creation python:1;
+                   global formaction string:display_pume_result" />
+<!-- a layout_lib macro -->
+<!-- $Id$ -->
+
+<metal:block define-macro="default_edit"
+  tal:define="layout options/layout;
+  ds options/datastructure;
+  dm ds/getDataModel;
+  formaction options/formaction;
+  creation creation|nothing;
+  metadata metadata|nothing;
+  type_name request/type_name|nothing;
+  ti python:type_name and getattr(here.portal_types,type_name,None) or getattr(here.portal_types,here.portal_type,None);
+  cpsmcat nocall:here/translation_service;
+  apply request/apply_button|nothing;
+  ">
+  <form action="" id="editForm" method="post" 
+        enctype="multipart/form-data" class="workflow"
+        tal:attributes="action formaction"
+        >
+  <table class="layoutDefault" summary="Form layout"
+         tal:condition="layout/rows">
+    <span tal:repeat="row python: layout['rows']" valign="top" >
+      <span tal:repeat="cell row">
+        <tr tal:define="widget cell/widget;
+              wid widget/getWidgetId;
+              err python:ds.getError(wid);
+              err_mapping python:ds.getErrorMapping(wid);
+              is_required python: widget.is_required and creation and ('create' not in widget.readonly_layout_modes);
+              tooltip_id python:wid + '_help';
+              widget_css_class cell/widget_css_class|nothing;
+              css_class python:test(err, 'row error','row')"
+              tal:condition="python: wid != 'passport'"
+              >
+          <div tal:attributes="class widget_css_class;
+          id python:widget.getHtmlWidgetId()+'_widget';"
+          >
+            <td>
+            <div class="label" tal:condition="widget/label_edit"
+                 tal:attributes="class python:test(is_required, 'label required','label')">
+              <label tal:content="widget/label_edit"
+                     tal:attributes="for cell/widget_input_area_id|nothing;">label</label>:
+            </div>
+            <button type="button" class="tooltipControl"
+                    tal:condition="widget/help"
+                    tal:attributes="onclick python:'toggleElementVisibility(\'%s\')' % tooltip_id;"> ? </button>
+            </td>
+            <td>
+            <span class="field">
+              <div tal:replace="structure cell/widget_rendered"/>
+            </span>
+            <div class="tooltipArea" style="visibility: hidden;"
+                 tal:condition="widget/help"
+                 tal:attributes="id tooltip_id;
+                 onclick python:'showElement(false, \'%s\')' % tooltip_id;"
+                 >
+              <tal:block tal:content="widget/help">This is the help for this field
+              </tal:block>
+            </div>
+            <tal:block condition="err">
+              <tal:block define="msg python:cpsmcat(err, mapping=err_mapping)">
+                <br /><em style="color: red"
+                          tal:content="msg">err</em>
+              </tal:block>
+            </tal:block>
+            </td>
+          </div>
+        </tr>
+      </span>
+    </span>
+  </table>
+  <br />
+  <input type="submit" class="standalone" name="cpsdocument_edit_button"
+         value="Save" 
+         id="cpsdocument_edit_button"
+         tal:condition="not:creation" />
+  <input type="submit" class="standalone" name="apply_admission"
+         value="apply for admission"
+         id="cpsdocument_edit_and_view_button"
+         tal:condition="apply" 
+         tal:attributes="value apply"/>
+  <input type="submit" 
+         class="standalone" 
+         name="cpsdocument_create_button"
+         value="apply"
+         tal:attributes="value options/button"
+         tal:condition="creation" />
+
+</form>
+</metal:block>
Index: /WAeUP_SRP/trunk/skins/waeup_default/layout_wo_object_edit.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/layout_wo_object_edit.pt	(revision 1393)
+++ /WAeUP_SRP/trunk/skins/waeup_default/layout_wo_object_edit.pt	(revision 1393)
@@ -0,0 +1,63 @@
+<tal:block define="global creation python:0;
+                   global formaction string:set_access_data" />
+<!-- a layout_lib macro -->
+<!-- $Id$ -->
+
+<metal:block define-macro="default_edit"
+  tal:define="layout options/layout;
+  ds options/datastructure;
+  dm ds/getDataModel;
+  cpsmcat nocall:here/translation_service;
+  ">
+  <table class="layoutDefault" summary="Form layout"
+         tal:condition="layout/rows">
+    <span tal:repeat="row python: layout['rows']" valign="top" >
+      <span tal:repeat="cell row">
+        <tr tal:define="widget cell/widget;
+              wid widget/getWidgetId;
+              err python:ds.getError(wid);
+              err_mapping python:ds.getErrorMapping(wid);
+              is_required python: widget.is_required and creation and ('create' not in widget.readonly_layout_modes);
+              tooltip_id python:wid + '_help';
+              widget_css_class cell/widget_css_class|nothing;
+              css_class python:test(err, 'row error','row')"
+              tal:condition="python: wid != 'passport'"
+              >
+          <div tal:attributes="class widget_css_class;
+          id python:widget.getHtmlWidgetId()+'_widget';"
+          >
+            <td>
+            <div class="label" tal:condition="widget/label_edit"
+                 tal:attributes="class python:test(is_required, 'label required','label')">
+              <label tal:content="widget/label_edit"
+                     tal:attributes="for cell/widget_input_area_id|nothing;">label</label>:
+            </div>
+            <button type="button" class="tooltipControl"
+                    tal:condition="widget/help"
+                    tal:attributes="onclick python:'toggleElementVisibility(\'%s\')' % tooltip_id;"> ? </button>
+            </td>
+            <td>
+            <span class="field">
+              <div tal:replace="structure cell/widget_rendered"/>
+            </span>
+            <div class="tooltipArea" style="visibility: hidden;"
+                 tal:condition="widget/help"
+                 tal:attributes="id tooltip_id;
+                 onclick python:'showElement(false, \'%s\')' % tooltip_id;"
+                 >
+              <tal:block tal:content="widget/help">This is the help for this field
+              </tal:block>
+            </div>
+            <tal:block condition="err">
+              <tal:block define="msg python:cpsmcat(err, mapping=err_mapping)">
+                <br /><em style="color: red"
+                          tal:content="msg">err</em>
+              </tal:block>
+            </tal:block>
+            </td>
+          </div>
+        </tr>
+      </span>
+    </span>
+  </table>
+</metal:block>
Index: /WAeUP_SRP/trunk/skins/waeup_utilities/fixLevel.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_utilities/fixLevel.py	(revision 1392)
+++ /WAeUP_SRP/trunk/skins/waeup_utilities/fixLevel.py	(revision 1393)
@@ -30,6 +30,6 @@
 values = scat.uniqueValuesFor('level')
 #query = ~ In("level",('100', '200', '300', '400', '500', '600'))
-query = In("level",('',))
-res = aq_students(query)
+#query = In("level",('',))
+#res = aq_students(query)
 #from Products.zdb import set_trace;set_trace()
 modified = []
Index: /WAeUP_SRP/trunk/skins/waeup_utilities/increaseReturningLevels.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_utilities/increaseReturningLevels.py	(revision 1392)
+++ /WAeUP_SRP/trunk/skins/waeup_utilities/increaseReturningLevels.py	(revision 1393)
@@ -10,5 +10,5 @@
 # $Id$
 """
-list Students for ClearanceOfficers
+increase the Level for returning Students
 """
 
