source: WAeUP_SRP/trunk/skins/waeup_utilities/fix06Verdict.py @ 9169

Last change on this file since 9169 was 2485, checked in by Henrik Bettermann, 17 years ago

getSessionResults.py: fetch verdict from results
aos.xml: ticket #371
logged_in.py: fixed

File size: 2.3 KB
Line 
1## Script (Python) "fix06Verdict"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: fixReturningSession.py 2456 2007-10-28 07:09:46Z henrik $
11"""
12"""
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18import logging
19logger = logging.getLogger('Skins.fix06Verdict')
20from Products.AdvancedQuery import Eq, Between, Le,In
21aq_students = context.students_catalog.evalAdvancedQuery
22
23request = context.REQUEST
24session = request.SESSION
25response = request.RESPONSE
26setheader = request.RESPONSE.setHeader
27students = context.portal_url.getPortalObject().campus.students
28#from string import Template
29#def rwrite(s):
30#    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
31#    response.write("%s<br>\n\r" % s)
32
33#logger.info('')
34
35query = ~ Eq('verdict','N/A') & ~ Eq('verdict','') & In('session',('2006/2007','06','6'))
36brains = aq_students(query)
37total = len(brains)
38logger.info('started editing %d students with session 06 and non-empty verdict' % total)
39count = 0
40commit_after = 100
41
42for brain in brains:
43    count += 1
44    if count and not count % commit_after:
45        context.waeup_tool.doCommit()
46        logger.info("Committing %s transactions, total %s" % (commit_after,count))
47    try:
48        study_course_doc = getattr(getattr(students,brain.id),'study_course').getContent()
49       
50        # final fix
51        if brain.matric_no:
52            verdict = study_course_doc.current_verdict
53        else:
54            verdict = ''
55        study_course_doc.edit(mapping = { "current_verdict": '',
56                                          "previous_verdict": verdict})
57
58        # Info: The logging message is wrong if not matric_no
59        logger.info("Current verdict of %s (%s, %s, %s, %s) moved to previous verdict" % (brain.id,
60                                          brain.matric_no,
61                                          brain.name,
62                                          brain.review_state,
63                                          brain.verdict,
64                                          ))
65    except:
66        #rwrite('>>>> not found %s study_course' % (brain.id))
67        pass
68logger.info('finished editing %d students' % total)
69
70return
Note: See TracBrowser for help on using the repository browser.