Index: WAeUP_SRP/trunk/Students.py
===================================================================
--- WAeUP_SRP/trunk/Students.py	(revision 394)
+++ WAeUP_SRP/trunk/Students.py	(revision 395)
@@ -34,4 +34,7 @@
         name = 'short_full_time'
         no_import = False
+        if not no_import:
+            no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
+            no_import.write('"MatricNo","EntryRegNo","CurrentSession","StudentLevel","fullname","FirstName","MiddleName","Lastname","FormerSurname","Sex","Nationality","State","LGA","PermanentAddress","PermanentAddressCity","CampusAddress","PhoneNumber","Emailaddress","Mode","CourseMajor","Faculty","Dept"\n')
         logger = logging.getLogger('%s_import' % name)
         logger.info('Start loading from %s.csv' % name)
@@ -48,4 +51,5 @@
         l = self.portal_catalog({'meta_type': "Certificate"})
         certs = {}
+        students_added = []
         for c in l:
             certs[c.id] = c.getObject()
@@ -54,10 +58,22 @@
             sid = student.get('MatricNo')
             certcode = makeCertificateCode(student.get('CourseMajor'))
+            if sid in students_added:
+                em = 'Student with ID %(MatricNo)s %(fullname)s already exists in this import\n' % student
+                logger.info(em)
+                no_import.write(em)
+                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
+                continue
             s = studs.get(sid,None)
             if certcode not in certs.keys():
                 em = 'Certificate with ID %s %s not found\n' % (certcode, student.get('CourseMajor'))
-                if not no_import:
-                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
-                    no_import.write('"MatricNo","EntryRegNo","CurrentSession","StudentLevel","fullname","FirstName","MiddleName","Lastname","FormerSurname","Sex","Nationality","State","LGA","PermanentAddress","PermanentAddressCity","CampusAddress","PhoneNumber","Emailaddress","Mode","CourseMajor","Faculty","Dept"\n')
+                logger.info(em)
+                no_import.write(em)
+                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
+                continue
+            level = student.get('StudentLevel')
+            try: 
+                int(level)
+            except:
+                em = 'Student with ID %(MatricNo)s StudentLevel is empty\n' % student
                 logger.info(em)
                 no_import.write(em)
@@ -69,4 +85,5 @@
                 students_folder.invokeFactory('Student', sid)
                 s = getattr(self,sid)
+                students_added.append(sid)
                 s.invokeFactory('StudentPersonal','personal')
                 sp = s.personal
@@ -108,5 +125,4 @@
                 # Level
                 #
-                level = student.get('StudentLevel')
                 l = getattr(sc,level,None)
                 if l is None:
@@ -128,7 +144,4 @@
             else:
                 em = 'Student with ID %(MatricNo)s %(fullname)s already exists\n' % student
-                if not no_import:
-                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
-                    no_import.write('"MatricNo","EntryRegNo","CurrentSession","StudentLevel","fullname","FirstName","MiddleName","Lastname","FormerSurname","Sex","Nationality","State","LGA","PermanentAddress","PermanentAddressCity","CampusAddress","PhoneNumber","Emailaddress","Mode","CourseMajor","Faculty","Dept"\n')
                 logger.info(em)
                 no_import.write(em)
