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 1459 2007-02-21 17:18:32Z joachim $ |
---|
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 | if str(member) not in ('admin','joachim'): |
---|
37 | return |
---|
38 | count = 0 |
---|
39 | line_count = 0 |
---|
40 | lines = [] |
---|
41 | res = scat() |
---|
42 | for sbrain in res: |
---|
43 | if str(sbrain.level) == '100': |
---|
44 | ec = "new" |
---|
45 | else: |
---|
46 | ec = "nor" |
---|
47 | erg = context.results_import(matric_no=sbrain.matric_no) |
---|
48 | if erg and erg[0].Level: |
---|
49 | level_res = erg[0].Level |
---|
50 | everdict = erg[0].Verdict |
---|
51 | level_cc = context.getLevelFromResultsCosCode(erg) |
---|
52 | #if level_cc == 0: |
---|
53 | #lc = "-" |
---|
54 | lc = 100*level_cc - int(level_res) |
---|
55 | verdict,elegible = context.getVerdict(everdict) |
---|
56 | if elegible: |
---|
57 | level = "%d00" % (level_cc + 1) |
---|
58 | context.students_catalog.modifyRecord(id = sbrain.id, |
---|
59 | level="", |
---|
60 | verdict = "") |
---|
61 | while True: |
---|
62 | ec = "nos" |
---|
63 | if not students.hasObject(sbrain.id): |
---|
64 | break |
---|
65 | student = getattr(students,sbrain.id) |
---|
66 | ec = "nyr" |
---|
67 | if not student.hasObject("study_course"): |
---|
68 | break |
---|
69 | study_course = getattr(student,"study_course") |
---|
70 | study_course.getContent().edit(mapping = {'current_level':level, |
---|
71 | 'current_verdict':verdict}) |
---|
72 | context.students_catalog.modifyRecord(id = sbrain.id, |
---|
73 | level=level, |
---|
74 | verdict=verdict) |
---|
75 | ec = "reg" |
---|
76 | break |
---|
77 | |
---|
78 | s = '"%s","%s","%s","%s","%s","%s","%s","%s"' % (str(lc),ec, |
---|
79 | sbrain.id, |
---|
80 | sbrain.matric_no, |
---|
81 | level_res, |
---|
82 | level_cc, |
---|
83 | everdict, |
---|
84 | verdict) |
---|
85 | #lines.append(s) |
---|
86 | else: |
---|
87 | s = '"","%s","%s","%s","",""' % (ec,sbrain.id,sbrain.matric_no) |
---|
88 | #lines.append(s) |
---|
89 | |
---|
90 | rwrite("%s<br />" %s) |
---|
91 | # count += 1 |
---|
92 | # if count > 60: |
---|
93 | # line_count += 1 |
---|
94 | # rwrite("<br />\n%3d " % line_count) |
---|
95 | # count = 0 |
---|
96 | |
---|
97 | rwrite("<br />\n Done" ) |
---|
98 | |
---|
99 | ##setheader('Content-type','text/semicolon-seperated-values') |
---|
100 | ##setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"') |
---|
101 | ##setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past |
---|
102 | ##setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 |
---|
103 | ##setheader('Cache-Control', 'post-check=0,pre-check=0') |
---|
104 | ##setheader('Pragma', 'no-cache') # HTTP/1.0 |
---|
105 | ##return '\n'.join(lines) |
---|
106 | |
---|