source: WAeUP_SRP/trunk/skins/waeup_utilities/fixLevelFromResults.py @ 5101

Last change on this file since 5101 was 1459, checked in by joachim, 18 years ago

use hasObject

  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
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"""
12list Students for ClearanceOfficers
13"""
14
15request = context.REQUEST
16session = request.SESSION
17response = request.RESPONSE
18setheader = request.RESPONSE.setHeader
19
20def rwrite(s):
21    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
22    response.write(s)
23
24wftool = context.portal_workflow
25mtool = context.portal_membership
26member = mtool.getAuthenticatedMember()
27roles = member.getRolesInContext(context)
28retcat = context.returning_import
29rcat = context.results_import
30scat = context.students_catalog
31from Products.AdvancedQuery import Eq, Between, Le,In
32aq_students = context.students_catalog.evalAdvancedQuery
33students = context.portal_url.getPortalObject().campus.students
34
35
36if str(member) not in ('admin','joachim'):
37    return
38count = 0
39line_count = 0
40lines = []
41res = scat()
42for 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
97rwrite("<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
Note: See TracBrowser for help on using the repository browser.