Index: /WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTables.py	(revision 634)
+++ /WAeUP_SRP/trunk/WAeUPTables.py	(revision 635)
@@ -48,4 +48,5 @@
     
     def deleteRecord(self, uid):
+        #import pdb;pdb.set_trace()
         self.uncatalog_object(uid)
     
@@ -78,4 +79,17 @@
         WAeUPTable.__init__(self, 'portal_accommodation')
 
+    def searchAndReserveBed(self, student_id,bed_type):
+        import pdb;pdb.set_trace()
+        records = self.searchResults({'student' : student_id})
+        if len(records) > 0:
+            return -1,"Student with Id %s already booked bed %s" % (student_id,records[0].bed)
+            
+        records = self.searchResults({'bed_type' : bed_type, "student": ''})
+        if len(records) == 0:
+            return -1,"no bed of this type available"
+        rec = records[0]
+        self.modifyRecord(bed=rec.bed,student=student_id)
+        return 1,rec.bed
+        
 
 InitializeClass(AccommodationTable)
@@ -90,5 +104,5 @@
 
 
-    def searchAndSetRecord(self, uid, jamb_reg_no):
+    def searchAndSetRecord(self, uid, student_id):
         #records = self.searchResults(uid=uid)
         records = self.searchResults({"%s" % self.key : uid})
@@ -104,10 +118,10 @@
                 record_data[field] = getattr(record, field)
             # Add the updated data:
-            record_data['student'] = jamb_reg_no
+            record_data['student'] = student_id
             self.catalog_object(dict2ob(record_data), uid)
             return 1
-        if record.student != jamb_reg_no:
+        if record.student != student_id:
             return 0
-        if record.student == jamb_reg_no:
+        if record.student == student_id:
             return 2
 
Index: /WAeUP_SRP/trunk/Widgets.py
===================================================================
--- /WAeUP_SRP/trunk/Widgets.py	(revision 634)
+++ /WAeUP_SRP/trunk/Widgets.py	(revision 635)
@@ -345,6 +345,9 @@
         pins = self.portal_pins
         pin = "%(p)s%(b)s%(n)s" % vars()
-        ref = datastructure[self.reference]
-        #import pdb;pdb.set_trace()
+        if self.reference == "":
+            ref = str(self.portal_membership.getAuthenticatedMember())
+        else:
+            ref = datastructure[self.reference]
+        import pdb;pdb.set_trace()
         ok = pins.searchAndSetRecord(pin,ref)
         while 1:
@@ -356,5 +359,8 @@
                 break
             if ok >= 1:
-                student = getStudentByRegNo(self,ref)
+                if self.isStudent():
+                    student = self.getStudentInfo()['student']
+                else:
+                    student = getStudentByRegNo(self,ref)
                 if student is None:
                     err = "Student not Found in validate SC"
Index: /WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml	(revision 634)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml	(revision 635)
@@ -14,5 +14,5 @@
   </field>
  <field name="reserved_rooms" meta_type="CPS String List Field">
-    <property name="default_expr"></property>
+    <property name="default_expr">string:101 102</property>
   </field>
   <field name="rooms_per_floor" meta_type="CPS Int Field">
Index: /WAeUP_SRP/trunk/profiles/default/types/AccoHall.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/types/AccoHall.xml	(revision 634)
+++ /WAeUP_SRP/trunk/profiles/default/types/AccoHall.xml	(revision 635)
@@ -8,5 +8,5 @@
  <property name="product">WAeUP_SRP</property>
  <property name="factory">addAccoHall</property>
- <property name="immediate_view">academics_contents</property>
+ <property name="immediate_view">accommodation_index</property>
  <property name="global_allow">True</property>
  <property name="filter_content_types">True</property>
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/accommodation_view.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/accommodation_view.pt	(revision 634)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/accommodation_view.pt	(revision 635)
@@ -93,10 +93,10 @@
                        % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))"
                        />
-                <input type="submit" name="folder_delete:method" value="button_delete"
+                <input type="submit" name="hall_delete:method" value="button_delete"
                        class="destructive" i18n:attributes="value"
                        tal:attributes="onclick python:'return window.confirm(\'%s\')' %
                        (cpsmcat('description_confirm_delete'), )" 
                        />
-                <input tal:condition="python: context.portal_type not in ('Semester','Certificate')"
+                <input tal:condition="python: 0 and context.portal_type not in ('Semester','Certificate')"
                        type="submit" name="id_rename_form:method"
                        class="context" value="Change Object ID" i18n:attributes="value" 
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/getAccoHallsInfo.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/getAccoHallsInfo.py	(revision 634)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/getAccoHallsInfo.py	(revision 635)
@@ -21,5 +21,5 @@
 info['is_manager'] = context.isManager()
 info['is_student'] = context.isStudent()
-info['action'] = "%s" % context.campus.absolute_url()
+info['action'] = "%s" % context.absolute_url()
 info['choosen_ids'] = request.get('ids',[])
 items = []
@@ -49,5 +49,5 @@
         if st:
             res = pa(student=st)
-            bt_list.append({'student': st, 'bed': res[0].bed })
+            res_list.append({'student': st, 'bed': res[0].bed })
 info['reserved'] = res_list
 
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_acco.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_acco.py	(revision 634)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/reserve_acco.py	(revision 635)
@@ -9,9 +9,5 @@
 pr = context.portal_registration
 
-
-type_name = 'StudentApplication'
-ti = context.portal_types[type_name]
-REQUEST.set('type_name',type_name)
-
+info = context.getStudentInfo()
 validate = REQUEST.has_key("cpsdocument_create_button")
 
@@ -25,11 +21,11 @@
                       ob={},
                       layout_mode='create',
-                      formaction = "acco_reserve",
+                      formaction = "reserve_acco",
                       button = "book Bed",
                       )
 if psm == 'invalid':
     return context.acco_reserve_form(rendered = res,
-                                 psm = "Please correct your input.",
-                                 #psm = "%s, %s" % (psm,ds),
+                                 #psm = "Please correct your input.",
+                                 psm = "%s, %s" % (psm,ds),
                                  firstlayout = True,
                                  lastlayout = True,
@@ -45,10 +41,21 @@
 elif psm == 'valid':
     s_id = ds.get('s_id')
-    pin = str(ds.get('app_ac_pin'))
-    return context.REQUEST.RESPONSE.redirect("%s/logged_in?__ac_name=%s&__ac_password=%s&pin=%s"
-          % (context.absolute_url(),s_id,pin.split('-')[2],pin))
+    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.acco_reserve_form(rendered = res,
+                                 psm = bed,
+                                 firstlayout = True,
+                                 lastlayout = True,
+                                 ds = ds,
+                                 )
+    else:
+        return context.acco_reserve_form(rendered = res,
+                                 psm = "successfully reserved bed %s" % bed,
+                                 firstlayout = True,
+                                 lastlayout = True,
+                                 ds = ds,
+                                 )
 
 
-return
-
-
Index: /WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 634)
+++ /WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 635)
@@ -39,3 +39,6 @@
 info['per'] = student.personal
 info['per_doc'] = student.personal.getContent()
+info['sex'] = 'male'
+if info['per_doc'].sex:
+    info['sex'] = 'female'
 return info
Index: /WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt	(revision 634)
+++ /WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt	(revision 635)
@@ -6,5 +6,5 @@
   ds options/datastructure;
   dm ds/getDataModel;
-  formaction formaction|string:student_edit;
+  formaction options/formaction|string:student_edit;
   creation creation|nothing;
   metadata metadata|nothing;
