Changeset 1491 for WAeUP_SRP


Ignore:
Timestamp:
25 Feb 2007, 15:06:54 (18 years ago)
Author:
joachim
Message:

move changes out of loop

File:
1 edited

Legend:

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

    r1490 r1491  
    5454commit_count = 0
    5555logger.info("started for %s students" % len(res))
     56to_change = {}
    5657for sbrain in res:
    5758    #count_full += 1
    5859    #rwrite("%s: %s %s %s <br />" % (count_full,sbrain.id,sbrain.entry_mode,sbrain.level))
    5960    student_obj = getattr(students,sbrain.id)
     61    changed = False
    6062    if sbrain.entry_mode == "":
    6163        if not student_obj.hasObject('application'):
    6264            rwrite("%s %s %s application not found <br />" % (sbrain.id,sbrain.entry_mode,level))
    6365            continue
     66        changed = True
    6467        app_doc = student_obj.application.getContent()
    6568        entry_mode = app_doc.entry_mode
     
    6770        entry_mode = sbrain.entry_mode
    6871    if entry_mode == "DE":
     72        changed = True
    6973        level = "200"
    7074    else:
    7175        level = "100"
    72     students_cat.modifyRecord(id=sbrain.id,
    73                               level=level,
    74                               entry_mode=entry_mode)
     76    if changed:
     77        d = {}
     78        d['id'] = sbrain.id
     79        d['level'] = level
     80        d['entry_mode'] = entry_mode
     81        to_change[sbrain.id] = d
     82##    students_cat.modifyRecord(id=sbrain.id,
     83##                              level=level,
     84##                              entry_mode=entry_mode)
    7585    if not student_obj.hasObject('study_course'):
    7686        rwrite("%s %s %s study_course not found <br />" % (sbrain.id,sbrain.entry_mode,level))
     
    8595        commit_count = 0
    8696    rwrite("%s: %s %s %s <br />" % (count,sbrain.id,entry_mode,level))
     97for entry in to_change.keys():
     98    students_cat.modifyRecord(**to_change[entry])
    8799rwrite("finished")
    88100logger.info("finished  %s students" % count)
Note: See TracChangeset for help on using the changeset viewer.