Index: /WAeUP_SRP/trunk/Accommodation.py
===================================================================
--- /WAeUP_SRP/trunk/Accommodation.py	(revision 1409)
+++ /WAeUP_SRP/trunk/Accommodation.py	(revision 1410)
@@ -11,4 +11,6 @@
 from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
 from Products.WAeUP_SRP.WAeUPTables import AccommodationTable
+import logging
+import csv,re,os
 import Globals
 import DateTime
@@ -90,4 +92,129 @@
 ###)
 
+    security.declareProtected(ModifyPortalContent,"importReservedBeds")###(
+    def importReservedBeds(self):
+        """load Reserved Beds from CSV"""
+        import transaction
+        import random
+        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
+        students_folder = self.portal_url.getPortalObject().campus.students
+        acco_folder = self.portal_url.getPortalObject().campus.accommodation
+        tr_count = 1
+        total = 0
+        name = 'ReservedBeds'
+        accommodation = self.portal_accommodation
+        students_cat = self.students_catalog
+        no_import = []
+        imported = []
+        logger = logging.getLogger('Import.%s' % name)
+        try:
+            beds = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
+        except:
+            logger.error('Error reading %s.csv' % name)
+            return
+        halls = {}
+        start = True
+        for bed in beds:
+            if start:
+                start = False
+                logger.info('start loading from %s.csv' % name)
+                s = ','.join(['"%s"' % fn for fn in bed.keys()])
+                imported.append(s)
+                no_import.append('%s,"Error"' % s)
+                format = ','.join(['"%%(%s)s"' % fn for fn in bed.keys()])
+                format_error = format + ',"%(Error)s"'
+                no_certificate = "no certificate %s" % format
+            matric_no = bed.get('matric_no')
+            jamb_reg_no = bed.get('jamb_reg_no')
+            if matric_no != '':
+                res = students_cat(matric_no = matric_no)
+                if not res:
+                    bed['Error'] = "No such student"
+                    no_import.append( format_error % bed)
+                    continue
+                student = res[0]
+            elif jamb_reg_no != '':
+                res = students_cat(jamb_reg_no = jamb_reg_no)
+                if not res:
+                    bed['Error'] = "No such student"
+                    no_import.append( format_error % bed)
+                    continue
+                student = res[0]
+            else:
+                bed['Error'] = "No such student"
+                no_import.append( format_error % bed)
+                continue
+            sid = student.id
+            names = bed.get('name').split()
+            n = 0
+            for na in names:
+                if na.endswith(','):
+                    names[n] = na[:-1]
+                n += 1
+            s_names = student.name.split()
+            found = False
+            for sn in s_names:
+                if sn.upper() in names:
+                    found = True
+                    break
+            if not found:
+                bed['Error'] = "Name mismatch %s %s" % (str(names),str(s_names))
+                no_import.append( format_error % bed)
+                continue
+            hall = bed.get('hall')
+            if hall not in halls.keys():
+                hall_object = getattr(acco_folder,hall, None)
+                if hall_object is None:
+                    bed['Error'] = "No such hall"
+                    no_import.append( format_error % bed)
+                    continue
+                halls[hall] = hall_doc = hall_object.getContent() 
+            bid = "%(hall)s_%(block)s_%(room)s_%(bed)s" % bed
+            res = accommodation(bed = bid)
+            psm = ''
+            while True:
+                if not res:
+                    psm = "No bed with this id"
+                    break
+                bed_brain = res[0]
+                if not bed_brain.bed_type.endswith("reserved"):
+                    psm = "Not a reserved bed"
+                    break
+                if bed_brain.student:
+                    psm = "Bed %s already reserved for %s" % (bid,bed_brain.student)
+                    break
+                if student.sex and not bed.get('block') in hall_doc.blocks_for_female:
+                    psm = "Sex does not match %s" % bid
+                    break
+                break
+            if psm != '':
+                bed['Error'] = psm
+                no_import.append( format_error % bed)
+                continue
+            accommodation.modifyRecord(bed = bid, student = sid)
+            imported.append( format % bed)
+            tr_count += 1
+            if tr_count > 1000:
+                if len(no_import) > 0:
+                    open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
+                             '\n'.join(no_import) + '\n')
+                    no_import = []
+                open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write(
+                                            '\n'.join(no_import) + "\n")
+                imported = []
+                em = '%d transactions commited total %s\n' % (tr_count,total)
+                transaction.commit()
+                regs = []
+                logger.info(em)
+                total += tr_count
+                tr_count = 0
+        #from pdb import set_trace;set_trace()
+        open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write(
+                                            '\n'.join(imported))
+        open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
+                                                '\n'.join(no_import))
+        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
+
+        
 InitializeClass(AccoFolder)
 
Index: /WAeUP_SRP/trunk/profiles/default/accommodation.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/accommodation.xml	(revision 1409)
+++ /WAeUP_SRP/trunk/profiles/default/accommodation.xml	(revision 1410)
@@ -1,3 +1,4 @@
 <?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
 <object name="portal_catalog" meta_type="WAeUP Table">
  <column value="bed"/>
Index: /WAeUP_SRP/trunk/profiles/default/catalog.xsl
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/catalog.xsl	(revision 1409)
+++ /WAeUP_SRP/trunk/profiles/default/catalog.xsl	(revision 1410)
@@ -23,5 +23,15 @@
             <xsl:sort select="@value"
                       order="ascending" />
-            <tr>
+            <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}">
               <td colspan="">
                 <xsl:value-of select="@value"/>
@@ -40,5 +50,15 @@
             <xsl:sort select="@name"
                       order="ascending" />
-            <tr>
+            <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}">
               <td colspan="">
                 <xsl:value-of select="@name"/>
Index: /WAeUP_SRP/trunk/profiles/default/courses_catalog.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/courses_catalog.xml	(revision 1409)
+++ /WAeUP_SRP/trunk/profiles/default/courses_catalog.xml	(revision 1410)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
 <?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
-<object name="courses_catalog" meta_type="CMF Catalog">
+<object name="courses_catalog" meta_type="WAeUP Table">
  <column value="code"/>
  <column value="faculty"/>
@@ -8,4 +8,5 @@
  <column value="level"/>
  <column value="credits"/>
+ <column value="passmark"/>
  <column value="semester"/>
  <index name="code" meta_type="FieldIndex">
Index: /WAeUP_SRP/trunk/profiles/default/schemas/certificate_course.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/certificate_course.xml	(revision 1409)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/certificate_course.xml	(revision 1410)
@@ -2,16 +2,5 @@
 <?xml-stylesheet type="text/xsl" href="schema.xsl"?>
 <object name="certificate_course" meta_type="CPS Schema">
- <field name="admin_status" meta_type="CPS String Field"/>
- <field name="certificate_code" meta_type="CPS String Field"/>
- <field name="certificate_code_org" meta_type="CPS String Field"/>
- <field name="code" meta_type="CPS String Field">
-  <property name="is_searchabletext">False</property>
- </field>
+ <field name="code" meta_type="CPS String Field" />
  <field name="core_or_elective" meta_type="CPS Boolean Field"/>
- <field name="semester" meta_type="CPS String Field"/>
- <field name="department" meta_type="CPS String Field"/>
-  <field name="level" meta_type="CPS String Field">
-    <property name="is_searchabletext">True</property>
-  </field>
-  <field name="session" meta_type="CPS String Field"/>
 </object>
Index: /WAeUP_SRP/trunk/profiles/default/types/types.xsl
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/types/types.xsl	(revision 1409)
+++ /WAeUP_SRP/trunk/profiles/default/types/types.xsl	(revision 1410)
@@ -101,4 +101,9 @@
               </td>
               <td>
+                <xsl:for-each select="permission">
+                  <xsl:value-of select="@value"/>
+                </xsl:for-each>
+              </td>
+              <td>
                 <xsl:value-of select="@category"/>
               </td>
Index: /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py	(revision 1409)
+++ /WAeUP_SRP/trunk/skins/waeup_accommodation/book_reserved_bed.py	(revision 1410)
@@ -54,5 +54,5 @@
 bl = ds.get('bed_letter')
 bid = "%s_%s_%s" % (hall_id,br,bl)
-res = acco_cat(bed = bed)
+res = acco_cat(bed = bid)
 psm = ''
 while True:
@@ -79,5 +79,5 @@
                                  button = "reserve bed",
                                  )
-acco_cat.modifyRecord(bed = bed, student = sid)
+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,
