Index: /WAeUP_SRP/trunk/Students.py
===================================================================
--- /WAeUP_SRP/trunk/Students.py	(revision 1774)
+++ /WAeUP_SRP/trunk/Students.py	(revision 1775)
@@ -93,448 +93,4 @@
     portal_type = meta_type
     security = ClassSecurityInfo()
-
-    security.declareProtected(ModifyPortalContent,"createDEStudents")###(
-    def createDEStudents(self):
-        """load Fulltime 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': "RegNumber",
-                 'jamb_lastname': "Name",
-                 'session': "Session",
-                 'pume_tot_score': "PUDE SCORE",
-                 ##'jamb_score': "JambScore",
-                 'entry_mode': "EntryMode",
-                 'jamb_sex': "Sex",
-                 '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 = 'DE_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.createDEStudents')
-        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
-            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',
-                         'entry_mode',
-                         #'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'] = '200'
-            dsc['study_course'] = cert_id
-            dsc['current_level'] = '200'
-            #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) > 1:
-                    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,"createNewStudents")###(
-    def createNewStudents(self):
-        """load Fulltime 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': "RegNumber",
-                 'jamb_lastname': "Name",
-                 'session': "Session",
-                 'pume_tot_score': "PUME SCORE",
-                 'jamb_score': "JambScore",
-                 'jamb_sex': "Sex",
-                 '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()
-            #import pdb;pdb.set_trace()
-            picture ="%s/import/pictures/%s.jpg" % (i_home,picture_id)
-            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,"createStudents")###(
@@ -1315,160 +871,4 @@
     ###)
 
-    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 = makeCertificateCode(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'))
-    ###)
 
     security.declareProtected(ModifyPortalContent,"updateStudyCourse")###(
Index: /WAeUP_SRP/trunk/Students.unused_methods.txt
===================================================================
--- /WAeUP_SRP/trunk/Students.unused_methods.txt	(revision 1774)
+++ /WAeUP_SRP/trunk/Students.unused_methods.txt	(revision 1775)
@@ -644,2 +644,605 @@
         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 = makeCertificateCode(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'))
+    ###)
+    
+    
+        security.declareProtected(ModifyPortalContent,"createDEStudents")###(
+    def createDEStudents(self):
+        """load Fulltime 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': "RegNumber",
+                 'jamb_lastname': "Name",
+                 'session': "Session",
+                 'pume_tot_score': "PUDE SCORE",
+                 ##'jamb_score': "JambScore",
+                 'entry_mode': "EntryMode",
+                 'jamb_sex': "Sex",
+                 '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 = 'DE_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.createDEStudents')
+        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
+            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',
+                         'entry_mode',
+                         #'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'] = '200'
+            dsc['study_course'] = cert_id
+            dsc['current_level'] = '200'
+            #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) > 1:
+                    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,"createNewStudents")###(
+    def createNewStudents(self):
+        """load Fulltime 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': "RegNumber",
+                 'jamb_lastname': "Name",
+                 'session': "Session",
+                 'pume_tot_score': "PUME SCORE",
+                 'jamb_score': "JambScore",
+                 'jamb_sex': "Sex",
+                 '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()
+            #import pdb;pdb.set_trace()
+            picture ="%s/import/pictures/%s.jpg" % (i_home,picture_id)
+            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'))
+    ###)
Index: /WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTool.py	(revision 1774)
+++ /WAeUP_SRP/trunk/WAeUPTool.py	(revision 1775)
@@ -687,5 +687,5 @@
                           {'id': 'personal',
                            'title': 'Personal Data',
-                           'wf_state': 'close',
+                           'wf_state': 'open',
                            'fields':
                              ('firstname',
@@ -701,5 +701,5 @@
                           {'id': 'study_course',
                            'title': 'Study Course',
-                           'wf_state': 'close',
+                           'wf_state': 'open',
                            'fields':
                              ('study_course',
@@ -709,4 +709,11 @@
                               'current_verdict',
                               )
+                              },
+                         'PaymentsFolder':
+                          {'id': 'payments',
+                           'title': 'Payments',
+                           'wf_state': 'open',
+                           'fields':
+                             ()
                               },
                          }
@@ -741,5 +748,5 @@
             sub_obj = getattr(student_obj,f2t[pt]['id'])
             sub_doc = sub_obj.getContent()
-            self.portal_workflow.doActionFor(sub_obj,'open',dest_container=sub_obj)
+            #self.portal_workflow.doActionFor(sub_obj,'open',dest_container=sub_obj)
             d['Title'] = f2t[pt]['title']
             for field in f2t[pt]['fields']:
@@ -816,8 +823,8 @@
         import transaction
         import random
-        
+
         pm = self.portal_membership
-        member = pm.getAuthenticatedMember()        
-        
+        member = pm.getAuthenticatedMember()
+
         logger = logging.getLogger('WAeUPTool.importData')
         current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
