Ignore:
Timestamp:
10 Jan 2007, 23:18:11 (18 years ago)
Author:
joachim
Message:

fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_utilities/createReturningStudent.py

    r1258 r1260  
    3333    return "Student MatricNo %s, StudentId %s Jamb %s created" % (matric_no,sid,jamb_reg_no)
    3434
    35 students = context.returning_import(emil="adf")
     35matric_nos = context.returning_import.uniqueValuesFor('matric_no')
    3636count = 1
    3737total = 0
    3838logger.info('"%s","Create Students start"' % (member))
    39 #from Products.zdb import set_trace;set_trace()
    40 for student in students:
    41     if context.students_catalog(matric_no=student.matric_no):
    42         logger.info('"Student already exists","%s"' % (student.matric_no))
     39letters = ('ABCDEFGHKLMNPQRSTUVWXYZ')
     40lc = 0
     41for matric_no in matric_nos:
     42    res = context.students_catalog(matric_no = matric_no)
     43    if len(res) == 1:
     44        #logger.info('"Student already exists","%s"' % (matric_no))
    4345        continue
    44     if count > 100:
    45         context.waeup_tool.createOne(students_folder,student,'Z',commit=True)
     46    elif len(res) > 1:
     47        logger.info('"Student with multiple entries","%s","%s" ' % (matric_no,len(res)))
     48        ids = [r.id for r in res if not r.id.startswith('A')]
     49        #from Products.zdb import set_trace;set_trace()
     50        for id in ids:
     51            context.students_catalog.deleteRecord(id)
     52        students_folder.manage_delObjects(ids)
     53        logger.info('"deleted students","%s" ' % " ".join(ids))
     54        continue
     55    student = context.returning_import(matric_no=matric_no)[0]
     56    letter = letters[lc]
     57    lc += 1
     58    if lc == len(letters):
     59        lc = 0
     60    context.waeup_tool.createOne(students_folder,student,letter)
     61    logger.info('"Student created","%s"' % (matric_no))
     62    count += 1
     63    if count > 10:
    4664        logger.info('"%s","Committed Students","%s", "%s" ' % (member,count,total))
    4765        total += count
    4866        count = 1
    49         if total > 500:
    50             break
    51     else:
    52         for letter in ('ABCDEFGHKLMNPQRSTUVWXY'):
    53             context.waeup_tool.createOne(students_folder,student,letter)
    54             count += 1
    5567logger.info('"%s","Create Students finish","%s"' % (member,total))
Note: See TracChangeset for help on using the changeset viewer.