source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_229_resolve.py @ 16153

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

Three bugs removed:

0 instead of '0'
context instead of self (twice)

  • Property svn:keywords set to Id
File size: 2.5 KB
RevLine 
[1879]1## Script (Python) "ti_229_resolve"
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: ti_229_resolve.py 1881 2007-06-12 08:03:32Z henrik $
11"""
12resolve ticket #229
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19import logging
20#>>>>>>>>>>>>>>>><
21logger = logging.getLogger('Skins.ti_229_resolve')
22# logger.info('already done on  by joachim')
23# return
24#<<<<<<<<<<<<<<<<<
25from Products.AdvancedQuery import Eq, Between, Le,In
26aq_students = context.students_catalog.evalAdvancedQuery
27
28request = context.REQUEST
29session = request.SESSION
30response = request.RESPONSE
31setheader = request.RESPONSE.setHeader
32students = context.portal_url.getPortalObject().campus.students
33#from string import Template
34def rwrite(s):
35    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
36    response.write("%s<br>\n\r" % s)
37
38logger.info('ti_229 started')
39
[1881]40query = In('level',(0,''))
[1879]41brains = aq_students(query)
42total = len(brains)
43logger.info('found %d students' % total)
44count = 0
45commit_after = 5
46for brain in brains:
47    try:
48        study_course = getattr(getattr(students,brain.id),'study_course')
49    except:
50        logger.info('study_course of %s not found' % brain.id)
51        continue
52    s_results = context.results_import(matric_no = brain.matric_no)
53    if s_results:
[1881]54        lnr = context.getLevelFromResultsCosCode(s_results)
[1879]55        level = "%d00" % lnr
[1881]56        verdict,eligible = context.getVerdict(s_results[0].Verdict)
[1879]57        if eligible:
58            level = "%d00" % (lnr + 1)
59    else:
60        logger.info('matric_no %s not found in results_import' % brain.matric_no)
61        continue
[1881]62    count += 1
63
[1879]64    study_course.getContent().edit(mapping={'current_level': level,
65                                            'current_verdict': verdict,
66                                           }
67                                  )
[1881]68    logger.info('%d of %d changed level/verdict of %s to %s/%s'  % (count,
[1879]69                                                                    total,
70                                                                    brain.id,
71                                                                    level,
72                                                                    verdict,
73                                                                   ))
74    if not count % commit_after:
75        context.waeup_tool.doCommit()
76        logger.info("committed %d transactions" % commit_after)
77logger.info('ti_229 finished for %d of %d' % (count,total))
[1881]78return
Note: See TracBrowser for help on using the repository browser.