Changeset 395
- Timestamp:
- 20 Aug 2006, 12:29:10 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r393 r395 34 34 name = 'short_full_time' 35 35 no_import = False 36 if not no_import: 37 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") 38 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') 36 39 logger = logging.getLogger('%s_import' % name) 37 40 logger.info('Start loading from %s.csv' % name) … … 48 51 l = self.portal_catalog({'meta_type': "Certificate"}) 49 52 certs = {} 53 students_added = [] 50 54 for c in l: 51 55 certs[c.id] = c.getObject() … … 54 58 sid = student.get('MatricNo') 55 59 certcode = makeCertificateCode(student.get('CourseMajor')) 60 if sid in students_added: 61 em = 'Student with ID %(MatricNo)s %(fullname)s already exists in this import\n' % student 62 logger.info(em) 63 no_import.write(em) 64 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) 65 continue 56 66 s = studs.get(sid,None) 57 67 if certcode not in certs.keys(): 58 68 em = 'Certificate with ID %s %s not found\n' % (certcode, student.get('CourseMajor')) 59 if not no_import: 60 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") 61 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') 69 logger.info(em) 70 no_import.write(em) 71 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) 72 continue 73 level = student.get('StudentLevel') 74 try: 75 int(level) 76 except: 77 em = 'Student with ID %(MatricNo)s StudentLevel is empty\n' % student 62 78 logger.info(em) 63 79 no_import.write(em) … … 69 85 students_folder.invokeFactory('Student', sid) 70 86 s = getattr(self,sid) 87 students_added.append(sid) 71 88 s.invokeFactory('StudentPersonal','personal') 72 89 sp = s.personal … … 108 125 # Level 109 126 # 110 level = student.get('StudentLevel')111 127 l = getattr(sc,level,None) 112 128 if l is None: … … 128 144 else: 129 145 em = 'Student with ID %(MatricNo)s %(fullname)s already exists\n' % student 130 if not no_import:131 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")132 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')133 146 logger.info(em) 134 147 no_import.write(em)
Note: See TracChangeset for help on using the changeset viewer.