Last change
on this file since 16680 was
3781,
checked in by Henrik Bettermann, 16 years ago
|
course_result_list.py : csv download of course results lists
ti_507_2_resolve.py : new script to reindex the mode index in students_catalog
WAeUPTables.py: enable caching for reindexing the students_catalog, but it's still very slow (therefore ti_507_2_resolve.py)
|
File size:
1.5 KB
|
Line | |
---|
1 | ## Script (Python) "ti_507_2_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_507_2_resolve.py 3780 2008-11-21 09:26:51Z henrik $ |
---|
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'): |
---|
22 | return |
---|
23 | |
---|
24 | import logging |
---|
25 | logger = logging.getLogger('Skins.ti_507_2_resolve') |
---|
26 | sc = context.students_catalog |
---|
27 | students = sc() |
---|
28 | logger.info('start') |
---|
29 | for student in students: |
---|
30 | if student.course: |
---|
31 | course = student.course |
---|
32 | certificate = context.certificates_catalog(code=course) |
---|
33 | if not certificate: |
---|
34 | logger.info("%s, certificate %s does not exist" % (student.id,course)) |
---|
35 | continue |
---|
36 | if certificate[0].study_mode: |
---|
37 | correct_mode = certificate[0].study_mode |
---|
38 | else: |
---|
39 | logger.info("%s, certificate %s has no study_mode" % (student.id,course)) |
---|
40 | continue |
---|
41 | if not student.mode: |
---|
42 | logger.info("%s had no study_mode" % (student.id)) |
---|
43 | if student.mode != correct_mode: |
---|
44 | old_mode = student.mode |
---|
45 | d = {} |
---|
46 | d['id'] = student.id |
---|
47 | d['mode'] = correct_mode |
---|
48 | sc.modifyRecord(**d) |
---|
49 | logger.info("%s, mode %s replaced by %s" % (student.id,old_mode,correct_mode)) |
---|
50 | logger.info('finished') |
---|
51 | |
---|
Note: See
TracBrowser for help on using the repository browser.