1 | ## Script (Python) "ti_519_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_519_resolve.py 3386 2008-03-27 16:22:52Z joachim $ |
---|
11 | """ |
---|
12 | """ |
---|
13 | try: |
---|
14 | from Products.zdb import set_trace |
---|
15 | except: |
---|
16 | def set_trace(): |
---|
17 | pass |
---|
18 | |
---|
19 | mtool = context.portal_membership |
---|
20 | member = mtool.getAuthenticatedMember() |
---|
21 | if str(member) not in ('admin','joachim'): |
---|
22 | return |
---|
23 | |
---|
24 | |
---|
25 | import logging |
---|
26 | import DateTime |
---|
27 | logger = logging.getLogger('Skins.ti_519_resolve') |
---|
28 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
29 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
30 | aq_portal = context.portal_catalog_real.evalAdvancedQuery |
---|
31 | applicants = context.applicants_catalog |
---|
32 | aq_applicants = applicants.evalAdvancedQuery |
---|
33 | pins = context.portal_pins |
---|
34 | #students_folder = context.portal_url.getPortalObject().campus.students |
---|
35 | |
---|
36 | request = context.REQUEST |
---|
37 | session = request.SESSION |
---|
38 | response = request.RESPONSE |
---|
39 | setheader = request.RESPONSE.setHeader |
---|
40 | count = 0 |
---|
41 | found = 0 |
---|
42 | commit_after = 100 |
---|
43 | logger.info('start') |
---|
44 | empty= {} |
---|
45 | for applicant in applicants(): |
---|
46 | if not (applicant.firstname or |
---|
47 | applicant.lastname or |
---|
48 | applicant.course1 or |
---|
49 | applicant.course2 |
---|
50 | ) and applicant.pin and applicant.status == "entered": |
---|
51 | d = {} |
---|
52 | key = d['key'] = getattr(applicant,applicants.key) |
---|
53 | d['pin'] = applicant.pin.replace('-','') |
---|
54 | empty[key] = d |
---|
55 | #set_trace() |
---|
56 | logger.info('found %d empty application records' % len(empty)) |
---|
57 | d = {'student':''} |
---|
58 | for applicant in empty.values(): |
---|
59 | d['pin'] = applicant['pin'] |
---|
60 | pins.modifyRecord(**d) |
---|
61 | applicants.deleteRecord(applicant['key']) |
---|
62 | logger.info("reenabled pin %(pin)s for reg_no %(key)s and deleted applicants record" % applicant) |
---|
63 | logger.info('finished') |
---|