Ignore:
Timestamp:
4 Feb 2008, 08:58:20 (17 years ago)
Author:
joachim
Message:

fix for #71 fceokene

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_utilities/ti_71fc_resolve.py

    r3084 r3098  
    2929aq_students = context.students_catalog.evalAdvancedQuery
    3030aq_portal = context.portal_catalog_real.evalAdvancedQuery
     31course_results = context.course_results
     32aq_course_results = course_results.evalAdvancedQuery
    3133students_folder = context.portal_url.getPortalObject().campus.students
    3234
     
    5254    student_id = level.getPath().split('/')[-3]
    5355    students[student_id] = level.getId
    54 
     56course_results_to_change = []
    5557for student_id,level in students.items():
    5658    study_course = getattr(getattr(students_folder,student_id),'study_course',None)
     
    5961        continue
    6062    #logger.info('%s renaming level' % (student_id))
    61     if level == '110':
    62         if hasattr(study_course,'110'):
    63             study_course.manage_renameObjects(('110',),('200',))
    64             logger.info('%s renamed level from 110 to 200' % (student_id))
     63    for level in ('110','210'):
     64        if hasattr(study_course,level):
     65            new_level = "%d" % (int(level) + 90)
     66            study_course.manage_renameObjects((level,),(new_level,))
     67            logger.info('%s renamed level from %s to %s' % (student_id,level,new_level))
     68            query = Eq('student_id',student_id) & Eq('level_id',level)
     69            results = aq_course_results(query)
     70            if results:
     71                for result in results:
     72                    d = {}
     73                    for field in course_results.schema():
     74                        d[field] = getattr(result,field)
     75                    d['level_id'] = new_level
     76                    d['old_key'] = d['key']
     77                    d['key'] = d['key'].replace(level,new_level)
     78                    course_results_to_change += d,
     79            else:
     80                logger.info('%s no course_results for %s' % (student_id,level))
    6581        else:
    66             logger.info('%s no level-object for 110' % (student_id))
    67     elif level == '210':
    68         if hasattr(study_course,'210'):
    69             study_course.manage_renameObjects(('210',),('300',))
    70             logger.info('%s renamed level from 110 to 200' % (student_id))
    71         else:
    72             logger.info('%s no level-object for 210' % (student_id))
     82            logger.info('%s no level-object for %s' % (student_id,level))
     83#set_trace()
     84for result in course_results_to_change:
     85    try:
     86        course_results.addRecord(**result)
     87        logger.info('%(student_id)s adding %(key)s' % result)
     88    except ValueError:
     89        set_trace()
     90        logger.info('%(student_id)s %(key)s already there' % result)
     91    logger.info('%(student_id)s deleting %(old_key)s' % result)
     92    course_results.deleteRecord(result['old_key'])
     93   
    7394logger.info('finished')
Note: See TracChangeset for help on using the changeset viewer.