source: WAeUP_SRP/trunk/skins/waeup_utilities/fixSessionKey.py @ 17864

Last change on this file since 17864 was 3961, checked in by Henrik Bettermann, 16 years ago

Widgets.admitOneStudent: entry_session and session must start with '0'
fixSessionKey.py: fix students_catalog, won't be used, because we will import fresh student data with session and entry_session columns. Only 08 students are affected.

File size: 1.5 KB
Line 
1## Script (Python) "fixSessionKey"
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: fixSessionKey.py 3132 2008-02-08 21:10:38Z 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'):
22    return
23
24import logging
25import DateTime
26logger = logging.getLogger('Skins.fixSessionKey')
27students = context.students_catalog()
28
29counter = 0
30for student in students:
31    counter += 1
32    modified = False
33    sid = student.id
34    try:
35        session = student.session
36        entry_session = student.entry_session
37        ls = len(session)
38        les = len (entry_session)
39    except:
40        #logger.info('%s failed' % (sid))
41        continue
42    if ls == 1:
43        session = '0%c' % session
44        modified = True
45    if les == 1:
46        entry_session = '0%c' % entry_session
47        modified = True
48    if  entry_session == '98' and session.lstrip('0') == '8':
49        modified = True
50        entry_session = '08'       
51    if modified:   
52        context.students_catalog.modifyRecord(id = sid,
53                                              session=session,
54                                              entry_session=entry_session)       
55        logger.info('%d: %s, %s, %s' % (counter, sid, session, entry_session))
56
57return 'finished!'
58
59
Note: See TracBrowser for help on using the repository browser.