Index: /WAeUP_SRP/trunk/Students.py
===================================================================
--- /WAeUP_SRP/trunk/Students.py	(revision 1699)
+++ /WAeUP_SRP/trunk/Students.py	(revision 1700)
@@ -538,4 +538,229 @@
     ###)
 
+    security.declareProtected(ModifyPortalContent,"createNewStudents")###(
+    def createParttimeStudents(self):
+        """load Parttime Studentdata from CSV values"""
+        import transaction
+        import random
+        #from pdb import set_trace
+        wftool = self.portal_workflow
+        students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject()
+        csv_d = {'jamb_reg_no': "Reg_No",
+                 'jamb_firstname': "Firstname",
+                 'jamb_middlename': "Middlename",
+                 'jamb_lastname': "Lastname",
+                 'jamb_sex': "Sex",
+                 'entry_mode': 'Entry_mode',
+                 'jamb_age': "Age",
+                 'jamb_state': "State",
+##                 'jamb_first_cos': "AdminCourse",
+                 'faculty': "AdminFaculty",
+                 'course_code': "AdmitCoscode",
+                 'stud_status':"AdmitStatus",
+                 'department': "AdmitDept",
+                 'jamb_lga': "LGA",
+                 'app_email': "email",
+                 'app_mobile': "PhoneNumbers",
+                 }
+        csv_fields = [f[1] for f in csv_d.items()]
+        tr_count = 0
+        total = 0
+        #name = 'pume_results'
+        name = 'Admitted'
+        no_import = []
+        s = ','.join(['"%s"' % fn for fn in csv_fields])
+        no_import.append('"Error",%s' % s)
+        format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields])
+        no_certificate = "no certificate %s" % format
+        open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write('\n'.join(no_import))
+        logger = logging.getLogger('Students.StudentsFolder.createNewStudents')
+        logger.info('Start loading from %s.csv' % name)
+        l = self.portal_catalog({'meta_type': "Certificate"})
+        certs = {}
+        cert_docs = {}
+        for f in l:
+            certs[f.getId] = f.getObject().getContent()
+        try:
+            result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
+        except:
+            logger.error('Error reading %s.csv' % name)
+            return
+        for jamb in result:
+            jamb['Error'] = "Processing "
+            logger.info(format % jamb)
+            jamb_reg_no = jamb.get(csv_d['jamb_reg_no'])
+            res = self.portal_catalog({'portal_type': "StudentApplication",
+                                     'SearchableText': jamb_reg_no })
+            if res:
+                em = 'Student with RegNo %s already exists\n' % jamb_reg_no
+                logger.info(em)
+                jamb['Error'] = "Student exists"
+                no_import.append(format % jamb)
+                continue
+            cert_id = makeCertificateCode(jamb.get(csv_d['course_code']))
+            if cert_id not in certs.keys():
+                em = 'No Certificate with ID %s \n' % cert_id
+                logger.info(em)
+                jamb['Error'] = "No Certificate %s" % cert_id
+                no_import.append( format % jamb)
+                continue
+            res = self.portal_pumeresults(jamb_reg_no = jamb_reg_no)
+            if len(res) == 1:
+                self.portal_pumeresults.modifyRecord(jamb_reg_no = jamb_reg_no,
+                                                     status = jamb.get(csv_d['stud_status']),
+                                                     )
+            jamb_reg_no =jamb.get(csv_d['jamb_reg_no'])
+            cert_doc = certs[cert_id]
+            catalog_entry = {}
+            catalog_entry['jamb_reg_no'] = jamb_reg_no
+            jamb_name = jamb.get(csv_d['jamb_lastname'])
+            jamb_name.replace('>','')
+            jamb_name.replace('<','')
+            names = jamb_name.split()
+            letter = names[-1][0].upper()
+            sid = self.generateStudentId(letter)
+            not_created = True
+            while not_created:
+                try:
+                    students_folder.invokeFactory('Student', sid)
+                    not_created = False
+                except BadRequest:
+                    sid = self.generateStudentId(letter)
+            catalog_entry['id'] = sid
+            tr_count += 1
+            logger.info('%(total)s+%(tr_count)s: Creating Student with ID %(sid)s REG-NO %(jamb_reg_no)s ' % vars())
+            student = getattr(self,sid)
+            student.manage_setLocalRoles(sid, ['Owner',])
+            student.invokeFactory('StudentPume','pume')
+            dp = {'Title': 'Pume Data'}
+            student.invokeFactory('StudentApplication','application')
+            da = {'Title': 'Application Data'}
+            da["jamb_lastname"] = jamb_name
+            da_fields = ('jamb_reg_no',
+                         'jamb_sex',
+                         #'jamb_state',
+                         'jamb_score',
+##                         'jamb_first_cos',
+                         'jamb_sex',
+                         'jamb_state',
+                         'jamb_lga',
+                         'app_email',
+                         'app_mobile',
+                         )
+            for f in da_fields:
+                da[f] = jamb.get(csv_d[f])
+            catalog_entry['email'] = jamb.get(csv_d['app_email'])
+            app = student.application
+            app_doc = app.getContent()
+            picture ="%s/import/pictures/%s.jpg" % (i_home,jamb_reg_no)
+            #import pdb;pdb.set_trace()
+            if os.path.exists(picture):
+                file = open(picture)
+                if False:
+                    img = PIL.Image.open(file)
+                    img.thumbnail((150,200),
+                                  resample=PIL.Image.ANTIALIAS)
+                    # We now need a buffer to write to. It can't be the same
+                    # as the inbuffer as the PNG writer will write over itself.
+                    outfile = StringIO()
+                    img.save(outfile, format=img.format)
+                else:
+                    outfile = file.read()
+                app_doc.manage_addFile('passport',
+                                       file=outfile,
+                                       title="%s.jpg" % jamb_reg_no)
+            app.getContent().edit(mapping=da)
+            app.manage_setLocalRoles(sid, ['Owner',])
+            #wftool.doActionFor(app,'close')
+            dp_fields = (
+                         #'pume_eng_score',
+                         #'pume_gen_score',
+                         'pume_tot_score',
+                         )
+            dp['pume_tot_score'] = jamb.get(csv_d['pume_tot_score']) or "No Option Shaded"
+            pume = student.pume
+            pume.getContent().edit(mapping=dp)
+            #wftool.doActionFor(pume,'close')
+            pume.manage_setLocalRoles(sid, ['Owner',])
+            #student.getContent().createSubObjects()
+            dp = {}
+            if len(names) == 3:
+                dp['firstname'] = names[0].capitalize()
+                dp['middlename'] = names[1].capitalize()
+                dp['lastname'] = names[2].capitalize()
+            elif len(names) == 2:
+                dp['firstname'] = names[0].capitalize()
+                dp['middlename'] = ''
+                dp['lastname'] = names[1].capitalize()
+            else:
+                dp['firstname'] = ''
+                dp['middlename'] = ''
+                dp['lastname'] = jamb_name
+            dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F'
+            catalog_entry['sex'] = dp['sex']
+            catalog_entry['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp
+            student.invokeFactory('StudentPersonal','personal')
+            per = student.personal
+            per_doc = per.getContent()
+            per_doc.edit(mapping = dp)
+            per.manage_setLocalRoles(sid, ['Owner',])
+            if jamb.get(csv_d['stud_status']) == "Admitted":
+                wftool.doActionFor(student,'pume_pass')
+                wftool.doActionFor(student,'admit')
+            else:
+                wftool.doActionFor(student,'pume_fail')
+                wftool.doActionFor(student,'reject_admission')
+                continue
+            #
+            # Clearance
+            #
+            student.invokeFactory('StudentClearance','clearance')
+            #wftool.doActionFor(student.clearance,'open')
+            dp = {'Title': 'Clearance/Eligibility Record'}
+            student.clearance.manage_setLocalRoles(sid, ['Owner',])
+            #
+            # Study Course
+            #
+            student.invokeFactory('StudentStudyCourse','study_course')
+            study_course = student.study_course
+            dsc = {}
+            #from_certificate = ['title',
+            #                   'max_elect',
+            #                   'max_pass',
+            #                   'n_core',
+            #                   'nr_years',
+            #                   'probation_credits',
+            #                   'promotion_credits',
+            #                   'start_level',
+            #                  ]
+            #for f in from_certificate:
+            #    dsc[f] = getattr(cert_doc,f)
+            #dsc['faculty'] = jamb.get(csv_d['faculty'])
+            #dsc['department'] = jamb.get(csv_d['department'])
+            catalog_entry['faculty'] = jamb.get(csv_d['faculty'])
+            catalog_entry['department'] = jamb.get(csv_d['department'])
+            catalog_entry['course'] = cert_id
+            #catalog_entry['level'] = getattr(cert_doc,'start_level')
+            catalog_entry['level'] = '100'
+            dsc['study_course'] = cert_id
+            dsc['entry_level'] = '100'
+            #dsc['entry_session'] = jamb.get(csv_d['session'])
+            study_course.getContent().edit(mapping=dsc)
+            self.students_catalog.addRecord(**catalog_entry)
+            if tr_count > 10:
+                if len(no_import) > 0:
+                    open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write(
+                             '\n'.join(no_import) + "\n")
+                    no_import = []
+                em = '%d transactions commited\n' % tr_count
+                transaction.commit()
+                logger.info(em)
+                total += tr_count
+                tr_count = 0
+        open("%s/import/%s_not_imported.csv" % (i_home,name),"a").write(
+                                                '\n'.join(no_import))
+        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
+    ###)
+
     security.declareProtected(ModifyPortalContent,"importReturningStudents")###(
     def importReturningStudents(self):
@@ -1088,12 +1313,4 @@
                     #result['Error'] = "No Course"
                     #logger.info(format_error % result)
-            result['key'] = key
-            try:
-                table.addRecord(**result)
-            except ValueError:
-                #import pdb;pdb.set_trace()
-                result['Error'] = "Duplicate"
-                no_import.append( format_error % result)
-                continue
             regs.append(key)
             imported.append(format % result)
@@ -1125,4 +1342,161 @@
                                     '\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'))
+    ###)
+
+    security.declareProtected(ModifyPortalContent,"importPreviousSessionStudents")###(
+    def importPreviousSessionStudents(self):
+        """load and create previous session students from CSV"""
+        import transaction
+        import random
+        wftool = self.portal_workflow
+        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
+        students_folder = self.portal_url.getPortalObject().campus.students
+        tr_count = 1
+        total = 0
+        #name = 'pume_results'
+        name = 'Previous'
+        keys = self.portal_schemas.import_student.keys()
+        keys += self.portal_schemas.import_student_level_data.keys()
+        not_imported = []
+        imported = []
+        certificates = {}
+        logger = logging.getLogger('Students.StudentsFolder.importPreviousSessionStudents')
+        try:
+            records = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
+        except:
+            logger.error('Error reading %s.csv' % name)
+            return
+        start = True
+        for record in records:
+            if start:
+                start = False
+                logger.info('Start loading from %s.csv' % name)
+                false_keys = [k for k in record.keys() if k not in keys]
+                right_keys = [k for k in record.keys() if k in keys]
+                if false_keys:
+                    logger.info('Fields %s not in schema' % false_keys)
+                s = ','.join(['"%s"' % k for k in right_keys])
+                imported.append(s)
+                not_imported.append('%s,"error"' % s)
+                format = ','.join(['"%%(%s)s"' % k for k in right_keys])
+                format_error = format + ',"%(error)s"'
+            study_course = record.get('study_course')
+            matric_no = record.get('matric_no')
+            student_res = self.students_catalog(matric_no = matric_no)
+            if student_res:
+                record['error'] = "Student exists"
+                not_imported.append(format_error % record)
+                continue
+            if study_course not in certificates.keys():
+                cert_res = self.portal_catalog(portal_type='Certificate',
+                                                   id = study_course)
+                if not cert_res:
+                    record['error'] = "No such studycourse"
+                    not_imported.append(format_error % record)
+                    continue
+                certificates[cert_res[0].id] = cert_res[0]
+            sid = self.generateStudentId('x',students_folder)
+            students_folder.invokeFactory('Student', sid)
+            #from pdb import set_trace;set_trace()
+            record['student_id'] = sid
+            student = getattr(self,sid)
+            student.manage_setLocalRoles(sid, ['Owner',])
+            student.invokeFactory('StudentApplication','application')
+            app = student.application
+            app_doc = app.getContent()
+            dict = {'Title': 'Application Data'}
+            dict["jamb_lastname"] = "%(firstname)s %(lastname)s %(middlename)s" % record
+            r2d = [
+                   ('entry_mode','entry_mode'),
+                   ('sex','jamb_sex'),
+                   ('jamb_score','jamb_score'),
+                   ('jamb_reg_no','jamb_reg_no'),
+                   ]
+            for r,d in r2d:
+                dict[d] = record[r]
+            app_doc.edit(mapping=dict)
+            app.manage_setLocalRoles(sid, ['Owner',])
+            wftool.doActionFor(app,'close')
+            record['sex'] = record['sex'] == 'F'
+            student.invokeFactory('StudentPersonal','personal')
+            dict = {}
+            r2d = [('firstname','firstname'),
+                   ('middlename','middlename'),
+                   ('lastname','lastname'),
+                   ('sex','sex'),
+                   ('email','email'),
+                   ('phone','phone'),
+                   ('address','perm_address'), 
+                   ]
+            for r,d in r2d:
+                dict[d] = record[r]
+            per = student.personal
+            per_doc = per.getContent()
+            per_doc.edit(mapping = dict)
+            per.manage_setLocalRoles(sid, ['Owner',])
+            #
+            # Clearance
+            #
+            student.invokeFactory('StudentClearance','clearance')
+            #wftool.doActionFor(student.clearance,'open')
+            clearance = getattr(student,'clearance')
+            dict = {'Title': 'Clearance/Eligibility Record'}
+            clearance.getContent().edit(mapping = dict)
+            student.clearance.manage_setLocalRoles(sid, ['Owner',])
+            #
+            # Study Course
+            #
+            student.invokeFactory('StudentStudyCourse','study_course')
+            study_course = student.study_course
+            dict = {}
+            r2d = [('session','current_session'),
+                   ('level','current_level'), 
+                   ('verdict','current_verdict'), 
+                   ('study_course','study_course'),
+                   ]
+            for r,d in r2d:
+                dict[d] = record[r]
+            study_course.getContent().edit(mapping=dict)
+            #
+            # Study Level
+            #
+            level = record['level']
+            study_course.invokeFactory('StudentStudyLevel',level)
+            study_level = getattr(study_course,level)
+            dict = {}
+            r2d = [('session','session'),
+                   ('level','code'), 
+                   ('verdict','verdict'), 
+                   ]
+            for r,d in r2d:
+                dict[d] = record[r]
+            study_level.getContent().edit(mapping=dict)
+            wftool.doActionFor(student,'return')
+            imported.append(format % record)
+            tr_count += 1
+            record['tr_count'] = tr_count
+            record['total'] = total
+            logger.info('%(total)s+%(tr_count)s: Creating Student %(student_id)s %(matric_no)s %(jamb_reg_no)s' % record)
+            if tr_count > 1000:
+                if len(not_imported) > 0:
+                    open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
+                             '\n'.join(not_imported)+'\n')
+                    not_imported = []
+                open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write(
+                                            '\n'.join(imported) + '\n')
+                imported = []
+                em = '%d transactions commited total %s' % (tr_count,total)
+                transaction.commit()
+                logger.info(em)
+                regs = []
+                total += tr_count
+                tr_count = 0
+        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(not_imported))
+        em = '%d transactions commited total %d' % (tr_count,total)
         logger.info(em)
         return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
@@ -1241,10 +1615,11 @@
     ###)
 
-    def generateStudentId(self,letter): ###(
+    def generateStudentId(self,letter,students = None): ###(
         import random
         r = random
+        if students is None:
+            students = self.portal_url.getPortalObject().campus.students
         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):
@@ -1263,5 +1638,4 @@
 
 ###)
-
 
 class Student(CPSDocument): ###(
@@ -1429,5 +1803,5 @@
         return "Level %s" % self.aq_parent.getId()
 
-    def create_course_results(self,cert_id,current_level):
+    def create_course_results(self,cert_id,current_level): ###(
         "create all courses in a level"
         aq_portal = self.portal_catalog.evalAdvancedQuery
@@ -1451,4 +1825,5 @@
                 course_result.getContent().edit(mapping=d)
                 transaction.commit()
+    ###)
 
 InitializeClass(StudentStudyLevel)
Index: /WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTables.py	(revision 1699)
+++ /WAeUP_SRP/trunk/WAeUPTables.py	(revision 1700)
@@ -25,5 +25,5 @@
 from AccessControl import ClassSecurityInfo
 from Products.CMFCore.permissions import ModifyPortalContent
-
+import urllib
 import DateTime,time
 import csv,re
@@ -77,5 +77,4 @@
 
     def deleteRecord(self, uid):
-        #import pdb;pdb.set_trace()
         self.uncatalog_object(uid)
 
@@ -230,10 +229,30 @@
     name = "students_catalog"
     key = "id"
-    interesting_types = ('Student',
-                         'StudentApplication',
-                         'StudentCLearance',
-                         'StudentPersonal',
-                         'StudentStudyCourse',
-                         )
+    affected_types = {   ###(
+                      'StudentApplication':
+                             ('jamb_reg_no',
+                              'entry_mode',
+                              'entry_session',
+                              ),
+                      'StudentClearance':
+                             ('matric_no',
+                              ),
+                         'StudentPersonal':
+                             ('name',
+                              'sex',
+                              'email',
+                              'phone',
+                              ),
+                         'StudentStudyCourse':
+                             ('course',
+                              'faculty',
+                              'department',
+                              'level',
+                              'study_mode',
+                              'session',
+                              'verdict',
+                              ),
+                         }
+    ###)
 
     def __init__(self):
@@ -241,144 +260,14 @@
         return
 
-    def get_review_state(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): ###(
-        "return the students review_state from portal_catalog"
-        cat_res = self.portal_catalog(id = sid)
-        if len(cat_res) != 1:
-            return None
-        return cat_res[0].review_state
-
-    def get_course(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students study_course"
-        if study_course_doc is None:
-            return None
-        return getattr(study_course_doc,'study_course',None)
-
-    def get_department(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students department"
-        if study_course_doc is None:
-            return None
-        certificate_res = self.portal_catalog(id = study_course_doc.study_course)
-        if len(certificate_res) != 1:
-            return None
-        return certificate_res[0].getPath().split('/')[-3]
-
-    def get_email(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students email from the personal"
-        if personal_doc is None:
-            return None
-        return getattr(personal_doc,'email',None)
-
-    def get_entry_mode(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students entry_mode from the application"
-        if application_doc is None:
-            return None
-        return getattr(application_doc,'entry_mode',None)
-
-    def get_jamb_reg_no(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students jamb_reg_no from the application"
-        if application_doc is None:
-            return None
-        return getattr(application_doc,'jamb_reg_no',None)
-
-    def get_faculty(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students faculty"
-        if study_course_doc is None:
-            return None
-        certificate_res = self.portal_catalog(id = study_course_doc.study_course)
-        if len(certificate_res) != 1:
-            return None
-        return certificate_res[0].getPath().split('/')[-4]
-
-    def get_level(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students study_course"
-        if study_course_doc is None:
-            return None
-        #from pdb import set_trace;set_trace()
-        return getattr(study_course_doc,'current_level',None)
-
-    def get_matric_no(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students matric_no from the clearance "
-        if clearance_doc is None:
-            return None
-        return getattr(clearance_doc,'matric_no',None)
-
-    def get_name(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students name from the personal"
-        if personal_doc is None:
-            return None
-        doc = personal_doc
-        return "%s %s %s" % (doc.firstname,doc.middlename,doc.lastname)
-
-    def get_phone(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students phone from the personal"
-        if personal_doc is None:
-            return None
-        return getattr(personal_doc,'phone',None)
-
-    def get_sex(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students sex from the personal"
-        if personal_doc is None:
-            return None
-        return getattr(personal_doc,'sex',None)
-
-    def get_verdict(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
-        "return the students study_course"
-        if study_course_doc is None:
-            return None
-        return getattr(study_course_doc,'current_verdict',None)
-    ###)
-
-    def refreshCatalog(self, clear=0, pghandler=None): ###(
-        """ re-index everything we can find """
-        students_folder = self.portal_url.getPortalObject().campus.students
-
-        cat = self._catalog
-        paths = self._catalog.uids.items()
-        if clear:
-            paths = tuple(paths)
-            cat.clear()
-
-        num_objects = len(paths)
-        if pghandler:
-            pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects)
-        for i in xrange(num_objects):
-            if pghandler: pghandler.report(i)
-            p = paths[i]
-            sid = p[0]
-            pcat_res = self.portal_catalog(id=sid)
-            if len(pcat_res) != 1:
-                continue
-            student_brain = pcat_res[0]
-            student_obj = student_brain.getObject()
-            if student_obj.hasObject('application'):
-                application_doc = getattr(student_obj,'application').getContent()
-            else:
-                application_doc = None
-            if student_obj.hasObject('clearance'):
-                clearance_doc = getattr(student_obj,'clearance').getContent()
-            else:
-                clearance_doc = None
-            if student_obj.hasObject('personal'):
-                personal_doc = getattr(student_obj,'personal').getContent()
-            else:
-                personal_doc = None
-            if student_obj.hasObject('study_course'):
-                study_course_doc = getattr(student_obj,'study_course').getContent()
-            else:
-                study_course_doc = None
-            data = {}
-            data['id'] = sid
-            for field in self.schema():
-                function = getattr(self,"get_%s" % field, None)
-                if function is None:
-                    continue
-                value = function(sid,application_doc,clearance_doc,personal_doc,study_course_doc)
-                if value is not None:
-                    data[field] = value
-            self.modifyRecord(**data)
-        if pghandler: pghandler.finish()
-    ###)
-
-    def manage_catalogReindex(self, REQUEST, RESPONSE, URL1):
+    def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None):
+        """ clears the whole enchilada """
+        self._catalog.clear()
+
+        if REQUEST and RESPONSE:
+            RESPONSE.redirect(
+              URL1 +
+              '/manage_catalogAdvanced?manage_tabs_message=Catalog%20Cleared')
+
+    def manage_catalogReindex(self, REQUEST, RESPONSE, URL1): ###(
         """ clear the catalog, then re-index everything """
 
@@ -388,5 +277,5 @@
         pgthreshold = self._getProgressThreshold()
         handler = (pgthreshold > 0) and ZLogHandler(pgthreshold) or None
-        self.refreshCatalog(clear=0, pghandler=handler)
+        self.refreshCatalog(clear=1, pghandler=handler)
 
         elapse = time.time() - elapse
@@ -399,7 +288,136 @@
                          'Total time: %s\n'
                          'Total CPU time: %s' % (`elapse`, `c_elapse`)))
-
-
-    security.declarePrivate('notify_event_listener')
+    ###)
+
+    def get_from_doc_department(self,doc): ###(
+        "return the students department"
+        if doc is None:
+            return None
+        certificate_res = self.portal_catalog(id = doc.study_course)
+        if len(certificate_res) != 1:
+            return None
+        return certificate_res[0].getPath().split('/')[-3]
+
+    def get_from_doc_faculty(self,doc):
+        "return the students faculty"
+        if doc is None:
+            return None
+        certificate_res = self.portal_catalog(id = doc.study_course)
+        if len(certificate_res) != 1:
+            return None
+        return certificate_res[0].getPath().split('/')[-4]
+
+    def get_from_doc_level(self,doc):
+        "return the students level"
+        if doc is None:
+            return None
+        return getattr(doc,'current_level',None)
+
+    def get_from_doc_study_mode(self,doc):
+        "return the students study_mode"
+        if doc is None:
+            return None
+        return getattr(doc,'current_study_mode',None)
+
+    def get_from_doc_entry_session(self,doc):
+        "return the students entry_session"
+        if doc is None:
+            return None
+        try:
+            digit = int(doc.jamb_reg_no[0])
+        except:
+            return "xx"
+        if digit < 8:
+            return "0%c" % doc.jamb_reg_no[0]
+        return "9%c" % doc.jamb_reg_no[0]
+
+    def get_from_doc_session(self,doc):
+        "return the students session"
+        if doc is None:
+            return None
+        return getattr(doc,'current_session',None)
+
+    def get_from_doc_course(self,doc):
+        "return the students study_course"
+        if doc is None:
+            return None
+        return getattr(doc,'study_course',None)
+
+    def get_from_doc_name(self,doc):
+        "return the students name from the personal"
+        if doc is None:
+            return None
+        return "%s %s %s" % (doc.firstname,doc.middlename,doc.lastname)
+
+    def get_from_doc_verdict(self,doc):
+        "return the students study_course"
+        if doc is None:
+            return None
+        return getattr(doc,'current_verdict',None)
+
+###)
+
+    def refreshCatalog(self, clear=0, pghandler=None): ###(
+        """ re-index everything we can find """
+        students_folder = self.portal_url.getPortalObject().campus.students
+
+        cat = self._catalog
+        paths = self._catalog.uids.items()
+        if clear:
+            paths = tuple(paths)
+            cat.clear()
+        students = self.portal_catalog(portal_type="Student")
+        num_objects = len(students)
+        if pghandler:
+            pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects)
+        for i in xrange(num_objects):
+            if pghandler: pghandler.report(i)
+            student_brain = students[i]
+            spath = student_brain.getPath()
+            student_obj = student_brain.getObject()
+            data = {}
+            sid = data['id'] = student_brain.getId
+            data['review_state'] = student_brain.review_state
+            sub_brains = self.portal_catalog(path = spath)
+            if len(sub_brains) > 1:
+                for sub_brain in sub_brains:
+                    if not sub_brain.portal_type in self.affected_types.keys():
+                        continue
+                    doc = sub_brain.getObject().getContent()
+                    for field in self.affected_types[sub_brain.portal_type]:
+                        if hasattr(self,'get_from_doc_%s' % field):
+                            data[field] = getattr(self,'get_from_doc_%s' % field)(doc)
+                        else:
+                            data[field] = getattr(doc,field)
+            elif len(sub_brains) == 1:
+                #import pdb;pdb.set_trace()
+                import_res = self.returning_import(id = sid)
+                if not import_res:
+                    continue
+                import_record = import_res[0]
+                data['matric_no'] = import_record.matric_no
+                data['sex'] = import_record.Sex == 'F'
+                data['name'] = "%s %s %s" % (import_record.Firstname,
+                                             import_record.Middlename,
+                                             import_record.Lastname)
+                data['matric_no'] = import_record.Entryregno
+            study_course = getattr(student_obj,'study_course',None)
+            current_level = data.get('level',None)
+            data['registered_courses'] = []
+            if study_course and current_level and current_level in study_course.objectIds():
+                level_obj = getattr(study_course,current_level)
+                courses = [] 
+                for c in level_obj.objectIds():
+                    if c.endswith('_co'):
+                        courses.append(c[:-3])
+                    else:
+                        courses.append(c)
+                data['registered_courses'] = courses 
+            self.addRecord(**data)
+        if pghandler: pghandler.finish()
+    ###)
+
+
+    security.declarePrivate('notify_event_listener') ###(
     def notify_event_listener(self,event_type,object,infos):
         "listen for events"
@@ -407,32 +425,33 @@
         mt = object.meta_type
         students_catalog = self.students_catalog
-        #if pt not in self.interesting_types:
-        #    return
-        #print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars()
+        if pt not in self.affected_types.keys():
+            return
         if not infos.has_key('rpath'):
             return
-        if pt == 'Student' and event_type == "workflow":
-            pass
-        elif mt == 'StudentApplication':
-            if event_type not in ('sys_modify_object'):
-                return
-            print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars()
+        rpl = infos['rpath'].split('/')
+        if pt == 'Student' and event_type == "sys_add_object":
+            student_id = object.id
+            try:
+                self.addRecord(id = student_id)
+            except ValueError:
+                pass
+            return
+        elif pt == 'CourseResult' and mt == 'CPS Proxy Folder':
             from pdb import set_trace;set_trace()
-            jamb_reg_no = getattr(object,'jamb_reg_no',None)
-            if jamb_reg_no is None:
-                return
-            student_id = infos['rpath'].split('/')[2]
-            self.fixName(student_id)
-            student_entry = students_catalog(id = student_id)[0]
-            if student_entry.jamb_reg_no == jamb_reg_no:
-                return
-            students_catalog.modifyRecord(id = student_id,
-                                          jamb_reg_no = jamb_reg_no)
-        elif mt == 'StudentPersonal':
-            if event_type not in ('sys_modify_object'):
-                return
-            print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars()
-            student_id = infos['rpath'].split('/')[2]
-            self.fixName(student_id)
+            
+        if event_type not in ('sys_modify_object'):
+            return
+        data = {}
+        if mt == 'CPS Proxy Folder':
+            return
+        #from pdb import set_trace;set_trace()
+        for field in self.affected_types[pt]:
+            if hasattr(self,'get_from_doc_%s' % field):
+                data[field] = getattr(self,'get_from_doc_%s' % field)(object)
+            else:
+                data[field] = getattr(object,field)
+        data['id'] = rpl[2]
+        students_catalog.modifyRecord(**data)
+    ###)
 
 
Index: /WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTool.py	(revision 1699)
+++ /WAeUP_SRP/trunk/WAeUPTool.py	(revision 1700)
@@ -531,5 +531,5 @@
     ###)
 
-    security.declareProtected(ModifyPortalContent,"getInvalidCallbackTransactions")###(
+    security.declareProtected(ModifyPortalContent,"getCallbacksFromLog")###(
     def getCallbacksFromLog(self,filename):
         """fix Online Payment Transactions from Z2.log entries"""
Index: /WAeUP_SRP/trunk/profiles/default/layouts/student_application.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/student_application.xml	(revision 1699)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/student_application.xml	(revision 1700)
@@ -154,5 +154,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="jamb_reg_no" meta_type="JambRegNo Widget">
+ <widget name="jamb_reg_no" meta_type="String Widget">
   <property name="title">JAMB Registration Number</property>
   <property name="fields">
Index: /WAeUP_SRP/trunk/profiles/default/returning_import.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/returning_import.xml	(revision 1699)
+++ /WAeUP_SRP/trunk/profiles/default/returning_import.xml	(revision 1700)
@@ -2,4 +2,5 @@
 <?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
 <object name="returning_import" meta_type="WAeUP Table">
+ <column value="id"/>
  <column value="matric_no"/>
  <column value="Entryregno"/>
@@ -25,3 +26,6 @@
   <indexed_attr value="matric_no"/>
  </index>
+ <index name="id" meta_type="FieldIndex">
+  <indexed_attr value="id"/>
+ </index>
 </object>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/import_student.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/import_student.xml	(revision 1699)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/import_student.xml	(revision 1700)
@@ -1,17 +1,22 @@
 <?xml version="1.0"?>
 <?xml-stylesheet type="text/xsl" href="schema.xsl"?>
-<object name="student_application" meta_type="CPS Schema">
+<object name="import_student" meta_type="CPS Schema">
  <field name="mode" meta_type="CPS String Field"/>
- <field name="fullname" meta_type="CPS String Field"/>
+ <field name="firstname" meta_type="CPS String Field"/>
+ <field name="middlename" meta_type="CPS String Field"/>
+ <field name="lastname" meta_type="CPS String Field"/>
  <field name="sex" meta_type="CPS String Field"/>
  <field name="jamb_reg_no" meta_type="CPS String Field"/>
  <field name="entry_mode" meta_type="CPS String Field"/>
+ <field name="jamb_score" meta_type="CPS Int Field"/>
+ <field name="pume_score" meta_type="CPS Int Field"/>
  <field name="faculty" meta_type="CPS String Field"/>
  <field name="department" meta_type="CPS String Field"/>
  <field name="study_course" meta_type="CPS String Field"/>
+ <field name="matric_no" meta_type="CPS String Field"/>
  <field name="state" meta_type="CPS String Field"/>
  <field name="lga" meta_type="CPS String Field"/>
- <field name="level" meta_type="CPS String Field"/>
- <field name="verdict" meta_type="CPS String Field"/>
+ <field name="phone" meta_type="CPS String Field"/>
+ <field name="email" meta_type="CPS String Field"/>
  <field name="address" meta_type="CPS String Field"/>
 </object>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/import_student_level_data.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/import_student_level_data.xml	(revision 1699)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/import_student_level_data.xml	(revision 1700)
@@ -3,6 +3,6 @@
 <object name="import_student_level_data" meta_type="CPS Schema">
  <field name="matric_no" meta_type="CPS String Field"/>
+ <field name="session" meta_type="CPS String Field"/>
  <field name="level" meta_type="CPS String Field"/>
  <field name="verdict" meta_type="CPS String Field"/>
 </object>
-
Index: /WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml	(revision 1699)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml	(revision 1700)
@@ -9,4 +9,5 @@
   <field name="objection_date" meta_type="CPS DateTime Field"/>
   <field name="jamb_age" meta_type="CPS Int Field"/>
+ <field name="import_mode" meta_type="CPS String Field"/>
  <field name="jamb_first_cos" meta_type="CPS String Field"/>
  <field name="jamb_first_uni" meta_type="CPS String Field"/>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/student_course_result.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/student_course_result.xml	(revision 1699)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/student_course_result.xml	(revision 1700)
@@ -4,13 +4,8 @@
  <field name="code" meta_type="CPS String Field"/>
  <field name="title" meta_type="CPS String Field"/>
- <field name="faculty_code" meta_type="CPS String Field"/>
- <field name="department_code" meta_type="CPS String Field"/>
  <field name="credits" meta_type="CPS Int Field"/>
  <field name="core_or_elective" meta_type="CPS Boolean Field"/>
- <field name="passmark" meta_type="CPS Int Field"/>
- <field name="ansbook" meta_type="CPS String Field"/>
  <field name="carry_level" meta_type="CPS String Field"/>
  <field name="grade" meta_type="CPS String Field"/>
- <field name="import_id" meta_type="CPS String Field"/>
  <field name="score" meta_type="CPS Int Field"/>
  <field name="status" meta_type="CPS String Field"/>
Index: /WAeUP_SRP/trunk/profiles/default/schemas/student_study_course.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/schemas/student_study_course.xml	(revision 1699)
+++ /WAeUP_SRP/trunk/profiles/default/schemas/student_study_course.xml	(revision 1700)
@@ -6,4 +6,6 @@
     <property name="is_searchabletext">True</property>
   </field>
+  <field name="current_session" meta_type="CPS String Field"/>
+  <field name="current_study_mode" meta_type="CPS String Field"/>
   <field name="current_level" meta_type="CPS String Field"/>
   <field name="current_verdict" meta_type="CPS String Field"/>
Index: /WAeUP_SRP/trunk/profiles/default/students_catalog.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/students_catalog.xml	(revision 1699)
+++ /WAeUP_SRP/trunk/profiles/default/students_catalog.xml	(revision 1700)
@@ -2,5 +2,53 @@
 <?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
 <object name="students_catalog" meta_type="WAeUP Table">
+ <object name="plaintext_lexicon" meta_type="ZCTextIndex Lexicon">
+  <element name="Whitespace splitter" group="Word Splitter"/>
+  <element name="Case Normalizer" group="Case Normalizer"/>
+  <element name="Remove listed stop words only" group="Stop Words"/>
+ </object>
+ <index name="id" meta_type="FieldIndex">
+  <indexed_attr value="id"/>
+ </index>
+ <index name="review_state" meta_type="FieldIndex">
+  <indexed_attr value="review_state"/>
+ </index>
+ <index name="name" meta_type="TextIndex">
+  <indexed_attr value="name"/>
+ </index>
+ <index name="jamb_reg_no" meta_type="FieldIndex">
+  <indexed_attr value="jamb_reg_no"/>
+ </index>
+ <index name="matric_no" meta_type="FieldIndex">
+  <indexed_attr value="matric_no"/>
+ </index>
+ <index name="faculty" meta_type="FieldIndex">
+  <indexed_attr value="faculty"/>
+ </index>
+ <index name="entry_mode" meta_type="FieldIndex">
+  <indexed_attr value="entry_mode"/>
+ </index>
+ <index name="entry_session" meta_type="FieldIndex">
+  <indexed_attr value="entry_session"/>
+ </index>
+ <index name="department" meta_type="FieldIndex">
+  <indexed_attr value="department"/>
+ </index>
+ <index name="level" meta_type="FieldIndex">
+  <indexed_attr value="level"/>
+ </index>
+ <index name="study_mode" meta_type="FieldIndex">
+  <indexed_attr value="study_mode"/>
+ </index>
+ <index name="verdict" meta_type="FieldIndex">
+  <indexed_attr value="verdict"/>
+ </index>
+ <index name="course" meta_type="FieldIndex">
+  <indexed_attr value="course"/>
+ </index>
+ <index name="registered_courses" meta_type="KeywordIndex">
+  <indexed_attr value="registered_courses"/>
+ </index>
  <column value="id"/>
+ <column value="review_state"/>
  <column value="matric_no"/>
  <column value="jamb_reg_no"/>
@@ -10,35 +58,11 @@
  <column value="department"/>
  <column value="course"/>
+ <column value="registered_courses"/>
  <column value="email"/>
  <column value="phone"/>
  <column value="level"/>
+ <column value="study_mode"/>
  <column value="verdict"/>
  <column value="entry_mode"/>
- <index name="id" meta_type="FieldIndex">
-  <indexed_attr value="id"/>
- </index>
- <index name="jamb_reg_no" meta_type="FieldIndex">
-  <indexed_attr value="jamb_reg_no"/>
- </index>
- <index name="matric_no" meta_type="FieldIndex">
-  <indexed_attr value="matric_no"/>
- </index>
- <index name="faculty" meta_type="KeywordIndex">
-  <indexed_attr value="faculty"/>
- </index>
- <index name="entry_mode" meta_type="KeywordIndex">
-  <indexed_attr value="entry_mode"/>
- </index>
- <index name="department" meta_type="KeywordIndex">
-  <indexed_attr value="department"/>
- </index>
- <index name="level" meta_type="KeywordIndex">
-  <indexed_attr value="current_level"/>
- </index>
- <index name="verdict" meta_type="KeywordIndex">
-  <indexed_attr value="current_verdict"/>
- </index>
- <index name="course" meta_type="KeywordIndex">
-  <indexed_attr value="study_course"/>
- </index>
+ <column value="entry_session"/>
 </object>
Index: /WAeUP_SRP/trunk/skins/waeup_custom/functions.js.dtml
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_custom/functions.js.dtml	(revision 1700)
+++ /WAeUP_SRP/trunk/skins/waeup_custom/functions.js.dtml	(revision 1700)
@@ -0,0 +1,330 @@
+<dtml-comment>
+CPS JavaScript functions
+$Id: functions.js.dtml 32288 2006-01-26 17:36:06Z tziade $
+</dtml-comment>
+
+<dtml-let last_modified="_.DateTime()-14" expires="_.DateTime()+1" >
+<dtml-call "REQUEST.RESPONSE.setHeader( 'Content-Type', 'text/javascript' )">
+<dtml-call "REQUEST.RESPONSE.setHeader( 'Last-Modified', last_modified.toZone('GMT').rfc822() )">
+<dtml-call "REQUEST.RESPONSE.setHeader( 'Cache-Control', 'max-age=36000, must-revalidate' )">
+<dtml-call "REQUEST.RESPONSE.setHeader( 'Expires', expires.toZone('GMT').rfc822() )" >
+</dtml-let>
+
+var msie5 = (navigator.userAgent.indexOf('MSIE 5') != -1);
+
+//************************************************************
+// Folder content
+var isSelected = false;
+
+function toggleSelect(toggleSelectButton, selectAllText, deselectAllText) {
+  formElements = toggleSelectButton.form.elements;
+
+  if (isSelected) {
+    for (i = 0; i < formElements.length; i++) {
+      formElements[i].checked = false;
+    }
+    isSelected = false;
+    toggleSelectButton.value = selectAllText;
+  } else {
+    for (i = 0; i < formElements.length; i++) {
+      formElements[i].checked = true;
+    }
+    isSelected = true;
+    toggleSelectButton.value = deselectAllText;
+  }
+}
+
+//************************************************************
+/**
+ * Toggles an element's visibility.
+ * Function to show tooltips.
+ * If your element is a span, you must use inline display instead of block
+ * XXX recognize div and span then automaticly choose the best display rule
+ */
+function toggleElementVisibility(id) {
+  element = document.getElementById(id);
+  if (element) {
+    //window.alert(element.tagName)
+    if (element.style.visibility == 'hidden') {
+      element.style.visibility = 'visible';
+      if (element.tagName == 'DIV') {
+        element.style.display = 'block';
+      } else if (element.tagName == 'SPAN') {
+        element.style.display = 'inline';
+      } else {
+        element.style.display = 'block';
+      }
+    } else {
+      element.style.visibility = 'hidden';
+      element.style.display = 'none';
+    }
+  }
+}
+
+function showElement(show, id) {
+  element = document.getElementById(id);
+  if (element) {
+    //window.alert(element.tagName)
+    if (show) {
+      element.style.visibility = 'visible';
+      if (element.tagName in ['DIV', 'P']) {
+        element.style.display = 'block';
+      } else {
+        element.style.display = 'inline';
+      }
+    } else {
+      element.style.visibility = 'hidden';
+      element.style.display = 'none';
+    }
+  }
+}
+
+//************************************************************
+function trim(s) {
+  if (s) {
+    return s.replace(/^\s*|\s*$/g, "");
+  }
+  return "";
+}
+
+//************************************************************
+function checkEmptySearch(formElem) {
+  var query = trim(formElem.SearchableText.value);
+  if (query != '') {
+    formElem.SearchableText.value = query;
+    return true;
+  }
+  formElem.SearchableText.value = query;
+  formElem.SearchableText.focus();
+  return false;
+}
+
+//************************************************************
+/**
+ * Sets focus on <input> elements that have a class attribute
+ * containing the class 'focus'.
+ * Examples:
+ * <input type="text" id="username" name="__ac_name" class="focus"/>
+ * <input type="text" id="searchableText" class="standalone giant focus"/>
+ *
+ * This function does not work on crappy MSIE5.0 and MSIE5.5.
+ */
+function setFocus() {
+  if (msie5) {
+    return false;
+  }
+  var elements = document.getElementsByTagName('input');
+  for (var i = 0; i < elements.length; i++) {
+    var nodeClass = elements[i].getAttributeNode('class');
+    //alert("nodeClass = " + nodeClass);
+    if (nodeClass) {
+      var classes = nodeClass.value.split(' ');
+      for (var j = 0; j < classes.length; j++) {
+        if (classes[j] == 'focus') {
+          elements[i].focus();
+          return true;
+        }
+      }
+    }
+  }
+}
+
+/**
+ * Validates that the input fields designated by the given ids are not empty.
+ * It returns true if all the input fields are not empty, it returns false
+ * otherwise.
+ * Example:
+ * <form onsubmit="return validateRequiredFields(['field1', 'field2'],
+ * ['Title', 'Comments'], 'are empty while they are required fields.')">
+ */
+function validateRequiredFields(fieldIds, fieldLabels, informationText) {
+  for (i = 0; i < fieldIds.length; i++) {
+    element = document.getElementById(fieldIds[i]);
+    if (element && !element.value) {
+      window.alert("'" + fieldLabels[i] + "' " + informationText);
+      return false;
+    }
+  }
+  return true;
+}
+
+//************************************************************
+function getSelectedRadio(buttonGroup) {
+  if (buttonGroup[0]) {
+    for (var i=0; i<buttonGroup.length; i++) {
+      if (buttonGroup[i].checked) {
+        return i
+      }
+    }
+  } else {
+    if (buttonGroup.checked) { return 0; }
+  }
+  return -1;
+}
+
+function getSelectedRadioValue(buttonGroup) {
+  var i = getSelectedRadio(buttonGroup);
+  if (i == -1) {
+    return "";
+  } else {
+    if (buttonGroup[i]) {
+    return buttonGroup[i].value;
+    } else {
+    return buttonGroup.value;
+    }
+  }
+}
+
+function getSelectedRadioId(buttonGroup) {
+  var i = getSelectedRadio(buttonGroup);
+  if (i == -1) {
+    return "";
+  } else {
+    if (buttonGroup[i]) {
+      return buttonGroup[i].id;
+    } else {
+      return buttonGroup.id;
+    }
+  }
+}
+
+/**
+ * Return the label content corresponding to a radio selection
+ */
+function getSelectedRadioLabel(buttonGroup) {
+  var id = getSelectedRadioId(buttonGroup);
+  if (id == "") {
+    return "";
+  } else {
+    for (var i=0; i<document.getElementsByTagName("label").length; i++) {
+      var element_label = document.getElementsByTagName("label")[i];
+      if (element_label.htmlFor == id) {
+        return element_label.firstChild.nodeValue;
+      }
+    }
+  }
+}
+
+
+//************************************************************
+/*
+    Used to highlight search terms
+    from Geir Bækholt, adapted for CPS
+
+ */
+function highlightSearchTerm() {
+  var query_elem = document.getElementById('searchGadget')
+  if (! query_elem){
+    return false
+  }
+  var query = query_elem.value
+  // _robert_ ie 5 does not have decodeURI
+  if (typeof decodeURI != 'undefined'){
+    query = unescape(decodeURI(query)) // thanks, Casper
+  }
+  else {
+    return false
+  }
+  if (query){
+    queries = query.replace(/\+/g,' ').split(/\s+/)
+    // make sure we start the right place and not higlight menuitems or breadcrumb
+    searchresultnode = document.getElementById('searchResults')
+    if (searchresultnode) {
+      for (q=0;q<queries.length;q++) {
+        // don't highlight reserved catalog search terms
+        if (queries[q].toLowerCase() != 'not'
+          && queries[q].toLowerCase() != 'and'
+          && queries[q].toLowerCase() != 'or') {
+          climb(searchresultnode,queries[q]);
+        }
+      }
+    }
+  }
+}
+
+function climb(node, word){
+  // traverse childnodes
+  if (! node){
+    return false
+  }
+  if (node.hasChildNodes) {
+    var i;
+    for (i=0;i<node.childNodes.length;i++) {
+      climb(node.childNodes[i],word);
+    }
+    if (node.nodeType == 3) {
+      checkforhighlight(node, word);
+      // check all textnodes. Feels inefficient, but works
+    }
+  }
+}
+
+function checkforhighlight(node,word) {
+  ind = node.nodeValue.toLowerCase().indexOf(word.toLowerCase())
+  if (ind != -1) {
+    if (node.parentNode.className != "highlightedSearchTerm"){
+      par = node.parentNode;
+      contents = node.nodeValue;
+      // make 3 shiny new nodes
+      hiword = document.createElement("span");
+      hiword.className = "highlightedSearchTerm";
+      hiword.appendChild(document.createTextNode(contents.substr(ind,word.length)));
+      par.insertBefore(document.createTextNode(contents.substr(0,ind)),node);
+      par.insertBefore(hiword,node);
+      par.insertBefore(document.createTextNode( contents.substr(ind+word.length)),node);
+      par.removeChild(node);
+    }
+  }
+}
+
+/************************************************************
+/**
+ * searchLanguage widget functions
+ * used to auto select languages checkbox/radio
+ * cf CPSSchemas/skins/cps_schemas/widget_searchlanguage_render.pt
+ */
+function searchLanguageCheckSelected(languages, no_language, language) {
+  var count=0;
+  for (var i=0; i<languages.length; i++) {
+    if (languages[i].checked) {
+      count++;
+    }
+  }
+  no_language.checked = (count <= 0);
+  language.checked = (count > 0);
+}
+
+function searchLanguageClearSelected(languages) {
+  for (i=0; i<languages.length; i++) {
+    languages[i].checked = 0;
+  }
+}
+
+function toggleLayers(more_block, more_items) {
+  var objMoreBlock = document.getElementById(more_block).style;
+  var objMoreItems = document.getElementById(more_items).style;
+  if(objMoreBlock.display == "block")
+    objMoreBlock.display = "none";
+  if(objMoreItems.display == "none")
+    objMoreItems.display = "block";
+}
+
+/************************************************************
+/**
+ * waeup specific functions
+ */
+
+/**
+ * submit_once(): Avoid multiple sendings of forms...
+ */
+
+submitted = false;
+function submit_once() {
+    if (submitted) {
+        alert("Your request is being processed.\nPlease be patient.");
+        event.returnValue = 0;    // work-around for IE
+        return 0;
+    }
+    submitted = true;
+    return 1;
+}
Index: eUP_SRP/trunk/skins/waeup_default/functions.js.dtml
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/functions.js.dtml	(revision 1699)
+++ 	(revision )
@@ -1,330 +1,0 @@
-<dtml-comment>
-CPS JavaScript functions
-$Id: functions.js.dtml 32288 2006-01-26 17:36:06Z tziade $
-</dtml-comment>
-
-<dtml-let last_modified="_.DateTime()-14" expires="_.DateTime()+1" >
-<dtml-call "REQUEST.RESPONSE.setHeader( 'Content-Type', 'text/javascript' )">
-<dtml-call "REQUEST.RESPONSE.setHeader( 'Last-Modified', last_modified.toZone('GMT').rfc822() )">
-<dtml-call "REQUEST.RESPONSE.setHeader( 'Cache-Control', 'max-age=36000, must-revalidate' )">
-<dtml-call "REQUEST.RESPONSE.setHeader( 'Expires', expires.toZone('GMT').rfc822() )" >
-</dtml-let>
-
-var msie5 = (navigator.userAgent.indexOf('MSIE 5') != -1);
-
-//************************************************************
-// Folder content
-var isSelected = false;
-
-function toggleSelect(toggleSelectButton, selectAllText, deselectAllText) {
-  formElements = toggleSelectButton.form.elements;
-
-  if (isSelected) {
-    for (i = 0; i < formElements.length; i++) {
-      formElements[i].checked = false;
-    }
-    isSelected = false;
-    toggleSelectButton.value = selectAllText;
-  } else {
-    for (i = 0; i < formElements.length; i++) {
-      formElements[i].checked = true;
-    }
-    isSelected = true;
-    toggleSelectButton.value = deselectAllText;
-  }
-}
-
-//************************************************************
-/**
- * Toggles an element's visibility.
- * Function to show tooltips.
- * If your element is a span, you must use inline display instead of block
- * XXX recognize div and span then automaticly choose the best display rule
- */
-function toggleElementVisibility(id) {
-  element = document.getElementById(id);
-  if (element) {
-    //window.alert(element.tagName)
-    if (element.style.visibility == 'hidden') {
-      element.style.visibility = 'visible';
-      if (element.tagName == 'DIV') {
-        element.style.display = 'block';
-      } else if (element.tagName == 'SPAN') {
-        element.style.display = 'inline';
-      } else {
-        element.style.display = 'block';
-      }
-    } else {
-      element.style.visibility = 'hidden';
-      element.style.display = 'none';
-    }
-  }
-}
-
-function showElement(show, id) {
-  element = document.getElementById(id);
-  if (element) {
-    //window.alert(element.tagName)
-    if (show) {
-      element.style.visibility = 'visible';
-      if (element.tagName in ['DIV', 'P']) {
-        element.style.display = 'block';
-      } else {
-        element.style.display = 'inline';
-      }
-    } else {
-      element.style.visibility = 'hidden';
-      element.style.display = 'none';
-    }
-  }
-}
-
-//************************************************************
-function trim(s) {
-  if (s) {
-    return s.replace(/^\s*|\s*$/g, "");
-  }
-  return "";
-}
-
-//************************************************************
-function checkEmptySearch(formElem) {
-  var query = trim(formElem.SearchableText.value);
-  if (query != '') {
-    formElem.SearchableText.value = query;
-    return true;
-  }
-  formElem.SearchableText.value = query;
-  formElem.SearchableText.focus();
-  return false;
-}
-
-//************************************************************
-/**
- * Sets focus on <input> elements that have a class attribute
- * containing the class 'focus'.
- * Examples:
- * <input type="text" id="username" name="__ac_name" class="focus"/>
- * <input type="text" id="searchableText" class="standalone giant focus"/>
- *
- * This function does not work on crappy MSIE5.0 and MSIE5.5.
- */
-function setFocus() {
-  if (msie5) {
-    return false;
-  }
-  var elements = document.getElementsByTagName('input');
-  for (var i = 0; i < elements.length; i++) {
-    var nodeClass = elements[i].getAttributeNode('class');
-    //alert("nodeClass = " + nodeClass);
-    if (nodeClass) {
-      var classes = nodeClass.value.split(' ');
-      for (var j = 0; j < classes.length; j++) {
-        if (classes[j] == 'focus') {
-          elements[i].focus();
-          return true;
-        }
-      }
-    }
-  }
-}
-
-/**
- * Validates that the input fields designated by the given ids are not empty.
- * It returns true if all the input fields are not empty, it returns false
- * otherwise.
- * Example:
- * <form onsubmit="return validateRequiredFields(['field1', 'field2'],
- * ['Title', 'Comments'], 'are empty while they are required fields.')">
- */
-function validateRequiredFields(fieldIds, fieldLabels, informationText) {
-  for (i = 0; i < fieldIds.length; i++) {
-    element = document.getElementById(fieldIds[i]);
-    if (element && !element.value) {
-      window.alert("'" + fieldLabels[i] + "' " + informationText);
-      return false;
-    }
-  }
-  return true;
-}
-
-//************************************************************
-function getSelectedRadio(buttonGroup) {
-  if (buttonGroup[0]) {
-    for (var i=0; i<buttonGroup.length; i++) {
-      if (buttonGroup[i].checked) {
-        return i
-      }
-    }
-  } else {
-    if (buttonGroup.checked) { return 0; }
-  }
-  return -1;
-}
-
-function getSelectedRadioValue(buttonGroup) {
-  var i = getSelectedRadio(buttonGroup);
-  if (i == -1) {
-    return "";
-  } else {
-    if (buttonGroup[i]) {
-    return buttonGroup[i].value;
-    } else {
-    return buttonGroup.value;
-    }
-  }
-}
-
-function getSelectedRadioId(buttonGroup) {
-  var i = getSelectedRadio(buttonGroup);
-  if (i == -1) {
-    return "";
-  } else {
-    if (buttonGroup[i]) {
-      return buttonGroup[i].id;
-    } else {
-      return buttonGroup.id;
-    }
-  }
-}
-
-/**
- * Return the label content corresponding to a radio selection
- */
-function getSelectedRadioLabel(buttonGroup) {
-  var id = getSelectedRadioId(buttonGroup);
-  if (id == "") {
-    return "";
-  } else {
-    for (var i=0; i<document.getElementsByTagName("label").length; i++) {
-      var element_label = document.getElementsByTagName("label")[i];
-      if (element_label.htmlFor == id) {
-        return element_label.firstChild.nodeValue;
-      }
-    }
-  }
-}
-
-
-//************************************************************
-/*
-    Used to highlight search terms
-    from Geir Bækholt, adapted for CPS
-
- */
-function highlightSearchTerm() {
-  var query_elem = document.getElementById('searchGadget')
-  if (! query_elem){
-    return false
-  }
-  var query = query_elem.value
-  // _robert_ ie 5 does not have decodeURI
-  if (typeof decodeURI != 'undefined'){
-    query = unescape(decodeURI(query)) // thanks, Casper
-  }
-  else {
-    return false
-  }
-  if (query){
-    queries = query.replace(/\+/g,' ').split(/\s+/)
-    // make sure we start the right place and not higlight menuitems or breadcrumb
-    searchresultnode = document.getElementById('searchResults')
-    if (searchresultnode) {
-      for (q=0;q<queries.length;q++) {
-        // don't highlight reserved catalog search terms
-        if (queries[q].toLowerCase() != 'not'
-          && queries[q].toLowerCase() != 'and'
-          && queries[q].toLowerCase() != 'or') {
-          climb(searchresultnode,queries[q]);
-        }
-      }
-    }
-  }
-}
-
-function climb(node, word){
-  // traverse childnodes
-  if (! node){
-    return false
-  }
-  if (node.hasChildNodes) {
-    var i;
-    for (i=0;i<node.childNodes.length;i++) {
-      climb(node.childNodes[i],word);
-    }
-    if (node.nodeType == 3) {
-      checkforhighlight(node, word);
-      // check all textnodes. Feels inefficient, but works
-    }
-  }
-}
-
-function checkforhighlight(node,word) {
-  ind = node.nodeValue.toLowerCase().indexOf(word.toLowerCase())
-  if (ind != -1) {
-    if (node.parentNode.className != "highlightedSearchTerm"){
-      par = node.parentNode;
-      contents = node.nodeValue;
-      // make 3 shiny new nodes
-      hiword = document.createElement("span");
-      hiword.className = "highlightedSearchTerm";
-      hiword.appendChild(document.createTextNode(contents.substr(ind,word.length)));
-      par.insertBefore(document.createTextNode(contents.substr(0,ind)),node);
-      par.insertBefore(hiword,node);
-      par.insertBefore(document.createTextNode( contents.substr(ind+word.length)),node);
-      par.removeChild(node);
-    }
-  }
-}
-
-/************************************************************
-/**
- * searchLanguage widget functions
- * used to auto select languages checkbox/radio
- * cf CPSSchemas/skins/cps_schemas/widget_searchlanguage_render.pt
- */
-function searchLanguageCheckSelected(languages, no_language, language) {
-  var count=0;
-  for (var i=0; i<languages.length; i++) {
-    if (languages[i].checked) {
-      count++;
-    }
-  }
-  no_language.checked = (count <= 0);
-  language.checked = (count > 0);
-}
-
-function searchLanguageClearSelected(languages) {
-  for (i=0; i<languages.length; i++) {
-    languages[i].checked = 0;
-  }
-}
-
-function toggleLayers(more_block, more_items) {
-  var objMoreBlock = document.getElementById(more_block).style;
-  var objMoreItems = document.getElementById(more_items).style;
-  if(objMoreBlock.display == "block")
-    objMoreBlock.display = "none";
-  if(objMoreItems.display == "none")
-    objMoreItems.display = "block";
-}
-
-/************************************************************
-/**
- * waeup specific functions
- */
-
-/**
- * submit_once(): Avoid multiple sendings of forms...
- */
-
-submitted = false;
-function submit_once() {
-    if (submitted) {
-        alert("Your request is being processed.\nPlease be patient.");
-        event.returnValue = 0;    // work-around for IE
-        return 0;
-    }
-    submitted = true;
-    return 1;
-}
Index: /WAeUP_SRP/trunk/skins/waeup_student/getStudentReviewState.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/getStudentReviewState.py	(revision 1699)
+++ /WAeUP_SRP/trunk/skins/waeup_student/getStudentReviewState.py	(revision 1700)
@@ -5,5 +5,5 @@
 ##bind script=script
 ##bind subpath=traverse_subpath
-##parameters=
+##parameters=student_id=None
 ##title=
 ##
@@ -17,5 +17,6 @@
 except:
     aq_portal = None
-student_id = context.getStudentId()
+if student_id is None:
+    student_id = context.getStudentId()
 query = Eq('id',student_id)
 res = aq_portal(query)
Index: /WAeUP_SRP/trunk/skins/waeup_student/list_students.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/list_students.py	(revision 1699)
+++ /WAeUP_SRP/trunk/skins/waeup_student/list_students.py	(revision 1700)
@@ -49,13 +49,17 @@
 newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*')
 #newquery = MatchRegexp('SearchableText','^5*')
-new_students = aq_portal(newquery)
-new_sids = []
-for ns in new_students:
-    new_sids.append(ns.getPath().split('/')[-2])
+#new_students = aq_portal(newquery)
+#set_trace()
+#new_sids = []
+#for ns in new_students:
+#    new_sids.append(ns.getPath().split('/')[-2])
+#set_trace()
 for student in cleared:
-    if student.getId not in new_sids:
-        continue
+##    if student.getId not in new_sids:
+##        continue
     erg = scat(id=student.getId)
     if not erg:
+        continue
+    if not erg[0].jamb_reg_no.startswith('6'):
         continue
     d = context.getFormattedStudentEntry(erg[0])
Index: /WAeUP_SRP/trunk/skins/waeup_utilities/readOnlinePaymentsFromLog.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_utilities/readOnlinePaymentsFromLog.py	(revision 1699)
+++ /WAeUP_SRP/trunk/skins/waeup_utilities/readOnlinePaymentsFromLog.py	(revision 1700)
@@ -95,5 +95,4 @@
                                                   ))
     if payment_doc.resp_code == "" and response_code == "00":
-        pd = {}
         review_state = wftool.getInfoFor(payment_obj,'review_state',None)
         if review_state != "opened":
@@ -104,10 +103,11 @@
             logger.info('%s review_state = %s' % (student_id,review_state))
             continue
-        pd['resp_code'] = 'IP'
-        pd['resp_desc'] = 'Payment approved by import, %s' % (DateTime.DateTime())
-        payment_doc.edit(mapping=pd)
+        readin['resp_code'] = 'IP ' + readin['resp_code']
+        readin['resp_desc'] = 'Payment approved by logfile import, %s. ' % (DateTime.DateTime()) \
+                              + readin['resp_desc']
+        payment_doc.edit(mapping=readin)
         if payment_doc.type_description.startswith('School Fee'):
             wftool.doActionFor(student_obj,'pay_school_fee')
-        logger.info('%s approves epayment for %s by import' % (member,student_id))
+        logger.info('%s approves epayment for %s by logfile import' % (member,student_id))
         wftool.doActionFor(payment_obj,'close')
         approved += 1
