source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_519_resolve.py @ 11851

Last change on this file since 11851 was 3386, checked in by joachim, 17 years ago

resolve #519

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
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"""
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18
19mtool = context.portal_membership
20member = mtool.getAuthenticatedMember()
21if str(member) not in ('admin','joachim'):
22    return
23
24
25import logging
26import DateTime
27logger = logging.getLogger('Skins.ti_519_resolve')
28from Products.AdvancedQuery import Eq, Between, Le,In
29aq_students = context.students_catalog.evalAdvancedQuery
30aq_portal = context.portal_catalog_real.evalAdvancedQuery
31applicants = context.applicants_catalog
32aq_applicants = applicants.evalAdvancedQuery
33pins = context.portal_pins
34#students_folder = context.portal_url.getPortalObject().campus.students
35
36request = context.REQUEST
37session = request.SESSION
38response = request.RESPONSE
39setheader = request.RESPONSE.setHeader
40count = 0
41found = 0
42commit_after = 100
43logger.info('start')
44empty= {}
45for 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()
56logger.info('found %d empty application records' % len(empty))
57d = {'student':''}
58for 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)
63logger.info('finished')                   
Note: See TracBrowser for help on using the repository browser.