Index: WAeUP_SRP/trunk/Accommodation.py
===================================================================
--- WAeUP_SRP/trunk/Accommodation.py	(revision 713)
+++ WAeUP_SRP/trunk/Accommodation.py	(revision 714)
@@ -49,7 +49,6 @@
             hall_gen['name'] = hall.Title
             count = 0
-            #reserved = [int(r) for r in h.reserved_rooms.split(',')]
-            reserved = [int(r) for r in re.split(',|\.| ',h.reserved_rooms)
-                                     if not re.search(r'\D',r) and r]
+            reserved = [(int(r.split('/')[0]),int(r.split('/')[1])) for r in re.split(',|\.| ',h.reserved_rooms)
+                                     if r]
             sex = 'male'
             if h.which_sex:
@@ -61,5 +60,5 @@
                             room_nr = floor*100 + room
                             bt = 're'
-                            if room_nr in reserved:
+                            if (block,room_nr) in reserved:
                                 bt = "reserved"
                             elif bed in h.beds_for_fresh:
Index: WAeUP_SRP/trunk/Students.py
===================================================================
--- WAeUP_SRP/trunk/Students.py	(revision 713)
+++ WAeUP_SRP/trunk/Students.py	(revision 714)
@@ -23,17 +23,6 @@
 MAX_TRANS = 1000
 
-def generateStudentId(letter):
-    import random
-    r = random
-    if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'):
-        letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY')
-    students = context.portal_catalog(meta_type = "StudentsFolder")[-1]
-    sid = "%c%d" % (letter,r.randint(99999,1000000))
-    while hasattr(students, sid):
-        sid = "%c%d" % (letter,r.randint(99999,1000000))
-    return sid 
-    #return "%c%d" % (r.choice('ABCDEFGHKLMNPQRSTUVWXY'),r.randint(99999,1000000))
-
-def getStudentByRegNo(self,reg_no):
+
+def getStudentByRegNo(self,reg_no): ###(
     """search student by JAMB Reg No and return StudentFolder"""
     search = ZCatalog.searchResults(self.portal_catalog,{'meta_type': 'StudentApplication',
@@ -43,4 +32,6 @@
         return None
     return search[0].getObject().aq_parent
+
+###)
 
 class StudentsFolder(CPSDocument): ###(
@@ -111,16 +102,9 @@
             if matric_no not in matrics:
                 matrics.append(matric_no)
-                sid = generateStudentId(student.get('Lastname')[0])
+                sid = self.generateStudentId(student.get('Lastname')[0])
                 #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
+                students_folder.invokeFactory('Student', sid)
                 logger.info('%(tr_count)s: Creating Student with ID %(sid)s Matric_no %(matric_no)s ' % vars())
-                not_created = True
-                while not_created:
-                    try:
-                        students_folder.invokeFactory('Student', sid)
-                        not_created = False
-                    except BadRequest:
-                        sid = generateStudentId()
-                logger.info('%(tr_count)s: Creating Student with ID %(sid)s Matric_no %(matric_no)s ' % vars())
-                s = getattr(self,sid)
+                student_obj = getattr(self,sid)
                 access_code = "%d" % random.randint(1000000000,9999999999)
                 self.portal_registration.addMember(sid,
@@ -129,15 +113,21 @@
                                                           'Student',))
                 pwl_dict = {'student_id': sid,'access_code':access_code}
-                s.invokeFactory('StudentApplication','application')
+                student_obj.invokeFactory('StudentApplication','application')
+                application = student_obj.application
                 da = {'Title': 'Application Data'}
-                s.invokeFactory('StudentPersonal','personal')
+                student_obj.invokeFactory('StudentPersonal','personal')
                 da['jamb_reg_no'] = student.get('EntryRegNo')
-                sp = s.personal
+                personal = student_obj.personal
                 dp = {'Title': 'Personal Data'}
-                s.invokeFactory('StudentClearance','clearance')
-                sc = s.clearance
+                student_obj.invokeFactory('StudentClearance','clearance')
+                clearance = student_obj.clearance
                 dc = {'Title': 'Clearance Data'}
                 dc['matric_no'] = matric_no
-                lga = student.get('State') + ' / ' + student.get('LGA')
+                state = student.get('State')
+                lga = student.get('LGA')
+                if state and lga:
+                    lga =  state + ' / ' + lga
+                else:
+                    lga = "None"
                 dc['lga'] = lga
                 dc['nationality'] = student.get('Nationality')
@@ -152,29 +142,29 @@
                 dp['campus_address'] = student.get('CampusAddress')
                 dp['phone'] = student.get('PhoneNumber')
-                s.application.getContent().edit(mapping=da)
-                sp.getContent().edit(mapping=dp)
-                sc.getContent().edit(mapping=dc)
+                application.getContent().edit(mapping=da)
+                personal.getContent().edit(mapping=dp)
+                clearance.getContent().edit(mapping=dc)
                 #
                 # Study Course
                 #
-                s.invokeFactory('StudentStudyCourse','study_course')
-                sc = s.study_course
+                student_obj.invokeFactory('StudentStudyCourse','study_course')
+                studycourse = student_obj.study_course
                 dsc = {}
                 dsc['study_course'] = certcode
                 css = student.get('CurrentSession') or '2004-2005'
                 cs = int(css.split('-')[0]) - 2000
-                cl = int(student.get('StudentLevel'))/100
+                cl = int(student.get('StudentLevel') or '100')/100
                 dsc['entry_session'] = "200%s" % (cs - cl)
                 dsc['clr_ac_pin'] = access_code
-                sc.getContent().edit(mapping=dsc)
+                studycourse.getContent().edit(mapping=dsc)
                 #
                 # Level
                 #
-                l = getattr(sc,level,None)
+                l = getattr(studycourse,level,None)
                 if l is None:
                     #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
                     logger.info('Creating Level %(StudentLevel)s for %(fullname)s' % student)
-                    sc.invokeFactory('StudentStudyLevel', level)
-                    l = getattr(sc, level)
+                    studycourse.invokeFactory('StudentStudyLevel', level)
+                    l = getattr(studycourse, level)
                     certificate = certs[certcode]
                     cert_level = getattr(certificate,level,None)
@@ -193,4 +183,5 @@
                 no_import.write(em)
                 no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
+                continue
             if tr_count > MAX_TRANS:
                 transaction.commit()
@@ -202,5 +193,11 @@
             pwl_dict.update(da)
             pwl_dict.update(dp)
+            wftool = self.portal_workflow
             pwlist.append(pwl_template.substitute(pwl_dict))
+            wftool.doActionFor(student_obj,'clear_and_validate')
+            wftool.doActionFor(application,'close')
+            wftool.doActionFor(clearance,'close')
+            wftool.doActionFor(personal,'close')
+        open("%s/import/pwlist-%s.csv" % (i_home,name),"w+").write('\n'.join(pwlist))
         return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     ###)
@@ -335,6 +332,5 @@
             names = jamb_name.split()
             letter = names[-1][0].upper()
-            sid = generateStudentId(letter)
-            #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
+            sid = self.generateStudentId(letter)
             not_created = True
             while not_created:
@@ -343,5 +339,5 @@
                     not_created = False
                 except BadRequest:
-                    sid = generateStudentId(letter)
+                    sid = self.generateStudentId(letter)
             logger.info('%(tr_count)s: Creating Student with ID %(sid)s REG-NO %(jamb_reg_no)s ' % vars())
             student = getattr(self,sid)
@@ -383,4 +379,17 @@
         """compose title"""
         return "Student Section"
+
+    def generateStudentId(self,letter): ###(
+        import random
+        r = random
+        if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'):
+            letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY')
+        students = self.portal_catalog(meta_type = "StudentsFolder")[-1]
+        sid = "%c%d" % (letter,r.randint(99999,1000000))
+        while hasattr(students, sid):
+            sid = "%c%d" % (letter,r.randint(99999,1000000))
+        return sid 
+        #return "%c%d" % (r.choice('ABCDEFGHKLMNPQRSTUVWXY'),r.randint(99999,1000000))
+    ###)
 
 InitializeClass(StudentsFolder)
Index: WAeUP_SRP/trunk/Widgets.py
===================================================================
--- WAeUP_SRP/trunk/Widgets.py	(revision 713)
+++ WAeUP_SRP/trunk/Widgets.py	(revision 714)
@@ -170,4 +170,37 @@
 
 widgetRegistry.register(CourseIdWidget)
+
+
+###)
+
+class WAeUPReservedRoomsWidget(CPSStringWidget): ###(
+    """ WAeUPReservedRooms Widget"""
+    meta_type = "WAeUPReservedRooms Widget"
+
+    def validate(self, datastructure, **kw):
+        """Validate datastructure and update datamodel."""
+        import re
+        valid = CPSStringWidget.validate(self, datastructure, **kw)
+        if not valid:
+            return 0
+        else:
+            widget_id = self.getWidgetId()
+            value = datastructure[widget_id]
+            err = 0
+            try:
+                reserved = [(int(r.split('/')[0]),int(r.split('/')[1])) for r in re.split(',|\.| ',value)
+                                     if r]
+            except ValueError,msg:
+                err = str(msg)
+            if err:
+                datastructure.setError(widget_id, err)
+            else:
+                datamodel = datastructure.getDataModel()
+                datamodel[self.fields[0]] = value
+            return not err
+
+InitializeClass(WAeUPReservedRoomsWidget)
+
+widgetRegistry.register(WAeUPReservedRoomsWidget)
 
 
Index: WAeUP_SRP/trunk/profiles/default/layouts/acco_hall.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts/acco_hall.xml	(revision 713)
+++ WAeUP_SRP/trunk/profiles/default/layouts/acco_hall.xml	(revision 714)
@@ -79,5 +79,5 @@
     <property name="max_value">5</property>
  </widget>
- <widget name="reserved_rooms" meta_type="String Widget">
+ <widget name="reserved_rooms" meta_type="WAeUPReservedRooms Widget">
   <property name="title">Reserved Rooms</property>
   <property name="fields">
Index: WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml	(revision 713)
+++ WAeUP_SRP/trunk/profiles/default/schemas/acco_hall.xml	(revision 714)
@@ -14,5 +14,5 @@
   </field>
  <field name="reserved_rooms" meta_type="CPS String List Field">
-    <property name="default_expr">string:101,102</property>
+    <property name="default_expr">string:1/101,2/102</property>
   </field>
   <field name="rooms_per_floor" meta_type="CPS Int Field">
