source: WAeUP_SRP/trunk/skins/waeup_utilities/FixApplicantsStatus.py @ 17937

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

no comment

File size: 1.6 KB
Line 
1## Script (Python) "fixApplicantsStatus"
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: fix_applicants_status.py 2145 2007-08-22 09:48:40Z joachim $
11"""
12"""
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18import logging
19logger = logging.getLogger('skins.fixApplicantsStatus')
20from Products.AdvancedQuery import Eq, Between, Le,In
21applicants = context.applicants_catalog
22aq_applicants = applicants.evalAdvancedQuery
23
24request = context.REQUEST
25session = request.SESSION
26response = request.RESPONSE
27setheader = request.RESPONSE.setHeader
28#from string import Template
29def rwrite(s):
30    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
31    response.write("%s" % s)
32def rwrite_ln(s):
33    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
34    response.write("%s<br>\n\r" % s)
35
36#logger.info('')
37brains = applicants()
38total = len(brains)
39logger.info('%d applicants' % total)
40count = 0
41to_change = []
42for brain in brains:
43    count += 1
44    if brain.pin and not brain.status:
45        to_change.append(brain.reg_no)
46    if count and not count % 200:
47        rwrite_ln('.')
48        rwrite('%d: ' % (count / 200))
49    else:
50        rwrite('.')
51logger.info('%d to change' % len(to_change))
52data = {'status': 'entered'}
53for reg_no in to_change:
54    data['reg_no'] = reg_no
55    applicants.modifyRecord(**data)
56    rwrite_ln('%s status set to entered' % reg_no)
57    logger.info('%s status set to entered' % reg_no)
58logger.info('%d changed' % len(to_change))
59
60
Note: See TracBrowser for help on using the repository browser.