1 | ## Script (Python) "ti_507_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_resolve.py 3353 2008-03-19 08:35:45Z 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_507_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 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
32 | |
---|
33 | request = context.REQUEST |
---|
34 | session = request.SESSION |
---|
35 | response = request.RESPONSE |
---|
36 | setheader = request.RESPONSE.setHeader |
---|
37 | logger.info('start') |
---|
38 | count = 0 |
---|
39 | found = 0 |
---|
40 | commit_after = 10000 |
---|
41 | certificates = context.getCertificatesDict() |
---|
42 | students = context.students_catalog() |
---|
43 | wrong = [] |
---|
44 | missing_courses = [] |
---|
45 | wrong_modes = [] |
---|
46 | for student in students: |
---|
47 | count += 1 |
---|
48 | if student.entry_mode and student.course: |
---|
49 | certificate = certificates.get(student.course,None) |
---|
50 | if certificate is None: |
---|
51 | if student.course not in missing_courses: |
---|
52 | missing_courses += student.course, |
---|
53 | logger.info('missing course %s' % student.course) |
---|
54 | continue |
---|
55 | entry_mode = student.entry_mode |
---|
56 | if entry_mode != certificate.get('study_mode','xxx'): |
---|
57 | wrong += student.id, |
---|
58 | if student.entry_mode not in wrong_modes: |
---|
59 | wrong_modes += student.entry_mode, |
---|
60 | logger.info('%s != %s' % (student.entry_mode, |
---|
61 | certificates[student.course]['study_mode'])) |
---|
62 | if wrong and not (len(wrong) % commit_after): |
---|
63 | logger.info('found %d wrong of %d' % (len(wrong),count)) |
---|
64 | |
---|
65 | logger.info('wrong modes %s' % (', '.join(wrong_modes))) |
---|
66 | logger.info('missing courses %s' % (', '.join(missing_courses))) |
---|
67 | logger.info('found %d wrong of %d' % (len(wrong),count)) |
---|