Index: /WAeUP_SRP/trunk/Students.py
===================================================================
--- /WAeUP_SRP/trunk/Students.py	(revision 1528)
+++ /WAeUP_SRP/trunk/Students.py	(revision 1529)
@@ -902,4 +902,89 @@
     ###)
 
+    security.declareProtected(ModifyPortalContent,"fixVerdicts")###(
+    def fixVerdicts(self,csv_file=None):
+        """fix wrong uploaded verdicts"""
+        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
+        if csv_file is None:
+            name = 'Verdicts'
+        else:
+            name = csv_file
+        st_cat = self.students_catalog
+        no_import = []
+        verdicts_voc = self.portal_vocabularies.verdicts
+        rverdicts = {}
+        for k,v in verdicts_voc.items():
+            rverdicts[v.upper()] = k
+        logger = logging.getLogger('fixVerdicts')
+        try:
+            verdicts = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
+        except:
+            logger.error('Error reading %s.csv' % name)
+            return
+        start = True
+        #import pdb;pdb.set_trace()
+        for verdict in verdicts:
+            if start:
+                start = False
+                logger.info('start loading from %s.csv' % name)
+                s = ','.join(['"%s"' % fn for fn in verdict.keys()])
+                no_import.append('%s,"Error"' % s)
+                format = ','.join(['"%%(%s)s"' % fn for fn in verdict.keys()])
+                format_error = format + ',"%(Error)s"'
+            matric_no = verdict.get('MAT NO')
+            if not matric_no:
+                continue
+            matric_no = matric_no.upper()
+            if matric_no == '':
+                continue
+            verdict_code = rverdicts.get(verdict.get('CATEGORY'),None)
+            if verdict_code is None:
+                continue
+            sres = st_cat(matric_no = matric_no)
+            if sres:
+                student_id = sres[0].id
+                student_obj = getattr(students_folder,student_id,None)
+                if student_obj:
+                    study_course = getattr(student_obj,'study_course',None)
+                    if study_course is None:
+                        verdict['Error'] = "Student did not yet log in"
+                        no_import.append( format_error % verdict)
+                        continue
+                try:
+                    st_cat.modifyRecord(id = student_id,
+                                    verdict=verdict_code)
+                except KeyError:
+                    student['Error'] = "Not found in students_catalog"
+                    no_import.append( format_error % student)
+                    continue
+                dsc = {}
+                dsc['current_verdict'] = verdict_code
+                study_course.getContent().edit(mapping=dsc)
+            tr_count += 1
+            if tr_count > 1000:
+                if len(no_import) > 0:
+                    open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
+                             '\n'.join(no_import) + '\n')
+                    no_import = []
+                em = '%d transactions commited total %s\n' % (tr_count,total)
+                transaction.commit()
+                regs = []
+                logger.info(em)
+                total += tr_count
+                tr_count = 0
+        open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
+                                                '\n'.join(no_import))
+        total += tr_count
+        em = '%d total transactions commited' % (total)
+        logger.info(em)
+        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
+    ###)
+
     security.declareProtected(ModifyPortalContent,"fixAllEntryModeForReturning")###(
     def fixAllEntryModeForReturning(self):
@@ -1671,5 +1756,5 @@
     ###)
 
-
+ 
     security.declareProtected(View,"fixOwnership")
     def fixOwnership(self):
