source: WAeUP_SRP/trunk/skins/waeup_utilities/fixReturningSession.py

Last change on this file was 2456, checked in by Henrik Bettermann, 17 years ago

mark deprecated vocabulary
use '000' for pre-studies (no longer missing value)
improve fixReturningSession.py (do not replace level by '000')
fix getNextInfo.py
fix logged_in.py

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1## Script (Python) "fixReturningSession"
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.fixReturningSession')
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('review_state','returning') & In('session',('2006/2007','06','6'))
36brains = aq_students(query)
37total = len(brains)
38logger.info('started editing %d students with session 06 in state returning' % 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        study_course_doc.edit(mapping = { "current_session": '05',
50                                          "current_level": ''})
51        #rwrite('found %s , %s ,%s, %s' % (brain.id,
52        #                                  study_course_doc.current_session,
53        #                                  brain.matric_no,
54        #                                  brain.name))
55        logger.info("Session and level of %s (%s, %s, %s) changed from ('%s', '%s') to ('%s', '%s')" % (brain.id,
56                                          brain.matric_no,
57                                          brain.name,
58                                          brain.review_state,
59                                          brain.session,
60                                          brain.level,
61                                          study_course_doc.current_session,
62                                          study_course_doc.current_level,
63                                          ))
64    except:
65        #rwrite('>>>> not found %s study_course' % (brain.id))
66        pass
67logger.info('finished editing %d students with session 06 in state returning' % total)
68
69return
Note: See TracBrowser for help on using the repository browser.