1 | ## Script (Python) "search_pins" |
---|
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: fixLevelFromResults.py 1391 2007-02-05 09:17:07Z henrik $ |
---|
11 | """ |
---|
12 | list Students for ClearanceOfficers |
---|
13 | """ |
---|
14 | |
---|
15 | request = context.REQUEST |
---|
16 | session = request.SESSION |
---|
17 | response = request.RESPONSE |
---|
18 | setheader = request.RESPONSE.setHeader |
---|
19 | |
---|
20 | #def rwrite(s): |
---|
21 | # response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
22 | # response.write(s) |
---|
23 | |
---|
24 | wftool = context.portal_workflow |
---|
25 | mtool = context.portal_membership |
---|
26 | member = mtool.getAuthenticatedMember() |
---|
27 | roles = member.getRolesInContext(context) |
---|
28 | retcat = context.returning_import |
---|
29 | rcat = context.results_import |
---|
30 | scat = context.students_catalog |
---|
31 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
32 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
33 | students = context.portal_url.getPortalObject().campus.students |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | |
---|
38 | if str(member) not in ('admin','joachim'): |
---|
39 | return |
---|
40 | count = 0 |
---|
41 | lc = 1 |
---|
42 | lines = [] |
---|
43 | #from Products.zdb import set_trace;set_trace() |
---|
44 | res = scat() |
---|
45 | for sbrain in res: |
---|
46 | if str(sbrain.level) == '100': |
---|
47 | ec = "new" |
---|
48 | else: |
---|
49 | ec = "nor" |
---|
50 | erg = context.results_import(matric_no=sbrain.matric_no) |
---|
51 | if erg and erg[0].Level: |
---|
52 | ec = "e" |
---|
53 | level = erg[0].Level |
---|
54 | for e in erg: |
---|
55 | ec = "E" |
---|
56 | if level != e.Level: |
---|
57 | ec = "%s:%s!=%s<br />\n" % (sbrain.matric_no,level,e.Level) |
---|
58 | level = "%d" % (int(level) + 100) |
---|
59 | |
---|
60 | # würde ich an dieser Stelle nicht machen (siehe unten) |
---|
61 | #context.students_catalog.modifyRecord(id = sbrain.id, level=level) |
---|
62 | |
---|
63 | while True: |
---|
64 | student = getattr(students,sbrain.id,None) |
---|
65 | ec = "nos" |
---|
66 | if student is None: |
---|
67 | break |
---|
68 | ec = "nyr" |
---|
69 | study_course = getattr(student,"study_course", None) |
---|
70 | if study_course is None: |
---|
71 | break |
---|
72 | # zum Testen auskommentiert |
---|
73 | #study_course.getContent().edit(mapping = {'current_level':level}) |
---|
74 | |
---|
75 | #dies ist der richtige Platz |
---|
76 | context.students_catalog.modifyRecord(id = sbrain.id, level=level) |
---|
77 | |
---|
78 | ec = "reg" |
---|
79 | break |
---|
80 | if sbrain.level: |
---|
81 | old_level = str(sbrain.level) |
---|
82 | else: |
---|
83 | old_level = 'non' |
---|
84 | # rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no +"--"+ old_level +"--"+ level +"<br />") |
---|
85 | |
---|
86 | lines.append('"%s","%s","%s","%s","%s"' % (ec,sbrain.id,sbrain.matric_no,old_level,level)) |
---|
87 | |
---|
88 | |
---|
89 | else: |
---|
90 | # rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no + "<br />") |
---|
91 | lines.append('"%s","%s","%s","",""' % (ec,sbrain.id,sbrain.matric_no)) |
---|
92 | |
---|
93 | # count += 1 |
---|
94 | # if count > 60: |
---|
95 | # lc += 1 |
---|
96 | # rwrite("<br />\n%3d " % lc) |
---|
97 | # count = 0 |
---|
98 | |
---|
99 | #rwrite("<br />\n Done" ) |
---|
100 | |
---|
101 | setheader('Content-type','text/semicolon-seperated-values') |
---|
102 | setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"') |
---|
103 | setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past |
---|
104 | setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 |
---|
105 | setheader('Cache-Control', 'post-check=0,pre-check=0') |
---|
106 | setheader('Pragma', 'no-cache') # HTTP/1.0 |
---|
107 | return '\n'.join(lines) |
---|
108 | |
---|