Changeset 395 for WAeUP_SRP/trunk


Ignore:
Timestamp:
20 Aug 2006, 12:29:10 (18 years ago)
Author:
joachim
Message:

import Students now checks for empty levels and dupplicate MatricelNr?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r393 r395  
    3434        name = 'short_full_time'
    3535        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')
    3639        logger = logging.getLogger('%s_import' % name)
    3740        logger.info('Start loading from %s.csv' % name)
     
    4851        l = self.portal_catalog({'meta_type': "Certificate"})
    4952        certs = {}
     53        students_added = []
    5054        for c in l:
    5155            certs[c.id] = c.getObject()
     
    5458            sid = student.get('MatricNo')
    5559            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
    5666            s = studs.get(sid,None)
    5767            if certcode not in certs.keys():
    5868                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
    6278                logger.info(em)
    6379                no_import.write(em)
     
    6985                students_folder.invokeFactory('Student', sid)
    7086                s = getattr(self,sid)
     87                students_added.append(sid)
    7188                s.invokeFactory('StudentPersonal','personal')
    7289                sp = s.personal
     
    108125                # Level
    109126                #
    110                 level = student.get('StudentLevel')
    111127                l = getattr(sc,level,None)
    112128                if l is None:
     
    128144            else:
    129145                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')
    133146                logger.info(em)
    134147                no_import.write(em)
Note: See TracChangeset for help on using the changeset viewer.