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 | """ |
---|
13 | try: |
---|
14 | from Products.zdb import set_trace |
---|
15 | except: |
---|
16 | def set_trace(): |
---|
17 | pass |
---|
18 | import logging |
---|
19 | logger = logging.getLogger('skins.fixApplicantsStatus') |
---|
20 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
21 | applicants = context.applicants_catalog |
---|
22 | aq_applicants = applicants.evalAdvancedQuery |
---|
23 | |
---|
24 | request = context.REQUEST |
---|
25 | session = request.SESSION |
---|
26 | response = request.RESPONSE |
---|
27 | setheader = request.RESPONSE.setHeader |
---|
28 | #from string import Template |
---|
29 | def rwrite(s): |
---|
30 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
31 | response.write("%s" % s) |
---|
32 | def 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('') |
---|
37 | brains = applicants() |
---|
38 | total = len(brains) |
---|
39 | logger.info('%d applicants' % total) |
---|
40 | count = 0 |
---|
41 | to_change = [] |
---|
42 | for 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('.') |
---|
51 | logger.info('%d to change' % len(to_change)) |
---|
52 | data = {'status': 'entered'} |
---|
53 | for 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) |
---|
58 | logger.info('%d changed' % len(to_change)) |
---|
59 | |
---|
60 | |
---|