source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_493_resolve.py @ 6239

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

improve logging

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1## Script (Python) "ti_493_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_493_resolve.py 3258 2008-02-29 09:44:47Z henrik $
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_493_resolve')
28from Products.AdvancedQuery import Eq, Between, Le,In
29aq_students = context.students_catalog.evalAdvancedQuery
30aq_portal = context.portal_catalog_real.evalAdvancedQuery
31payments_catalog = context.payments_catalog
32aq_payments = payments_catalog.evalAdvancedQuery
33students_folder = context.portal_url.getPortalObject().campus.students
34
35request = context.REQUEST
36session = request.SESSION
37response = request.RESPONSE
38setheader = request.RESPONSE.setHeader
39def rwrite(s):
40    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
41    response.write("%s<br>\n\r" % s)
42logger.info('start')
43portal_payments = aq_portal(Eq('portal_type','Payment'))
44sc_payments = aq_payments(Eq('type','sc'))
45logger.info('found %d payments, %d SC payments' % (len(portal_payments),len(sc_payments)))
46student_ids = [r.student_id for r in sc_payments]
47count = 0
48found = 0
49set_trace()
50for payment in portal_payments:
51    count +=1
52    student_id = payment.relative_path.split('/')[2]
53    if student_id in student_ids:
54        doc = payment.getObject().getContent()
55        session_id = doc.type_description[doc.type_description.find('/')-2:doc.type_description.find('/')]
56        if session_id == doc.session_id:
57            continue
58        found += 1
59        logger.info("%d of %d: editing payment of %s, %s, %s, session_id from %s to %s" % (found,count,
60                                                               student_id,
61                                                               doc.date,
62                                                               doc.type_description,
63                                                               doc.session_id,
64                                                               session_id))
65        #doc.edit({'session_id': session_id})
66logger.info('finished editing %d' % found)
Note: See TracBrowser for help on using the repository browser.