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

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

use hasObject

  • Property svn:keywords set to Id
File size: 3.6 KB
RevLine 
[1387]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
[1391]7##parameters=
[1387]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
[1391]18setheader = request.RESPONSE.setHeader
19
[1407]20def rwrite(s):
21    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
22    response.write(s)
[1409]23
[1387]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
[1391]35
[1387]36if str(member) not in ('admin','joachim'):
[1391]37    return
[1387]38count = 0
[1401]39line_count = 0
[1391]40lines = []
[1387]41res = scat()
42for sbrain in res:
[1391]43    if str(sbrain.level) == '100':
44        ec = "new"
45    else:
46        ec = "nor"
[1387]47    erg = context.results_import(matric_no=sbrain.matric_no)
48    if erg and erg[0].Level:
[1407]49        level_res = erg[0].Level
[1401]50        everdict = erg[0].Verdict
[1407]51        level_cc = context.getLevelFromResultsCosCode(erg)
[1408]52        #if level_cc == 0:
53            #lc = "-"
54        lc = 100*level_cc - int(level_res)
[1401]55        verdict,elegible = context.getVerdict(everdict)
56        if elegible:
[1407]57            level = "%d00" % (level_cc + 1)
[1434]58        context.students_catalog.modifyRecord(id = sbrain.id,
59                                              level="",
60                                              verdict = "")
[1387]61        while True:
[1388]62            ec = "nos"
[1459]63            if not students.hasObject(sbrain.id):
[1387]64                break
[1459]65            student = getattr(students,sbrain.id)
[1388]66            ec = "nyr"
[1459]67            if not student.hasObject("study_course"):
[1387]68                break
[1459]69            study_course = getattr(student,"study_course")
[1434]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)
[1388]75            ec = "reg"
[1387]76            break
[1392]77
[1409]78        s = '"%s","%s","%s","%s","%s","%s","%s","%s"' % (str(lc),ec,
[1401]79                                                           sbrain.id,
80                                                           sbrain.matric_no,
[1407]81                                                           level_res,
82                                                           level_cc,
[1401]83                                                           everdict,
[1407]84                                                           verdict)
85        #lines.append(s)
[1388]86    else:
[1407]87        s = '"","%s","%s","%s","",""' % (ec,sbrain.id,sbrain.matric_no)
88        #lines.append(s)
[1409]89
[1407]90    rwrite("%s<br />" %s)
[1388]91#    count += 1
92#    if count > 60:
[1401]93#        line_count += 1
94#        rwrite("<br />\n%3d " % line_count)
[1388]95#        count = 0
96
[1407]97rwrite("<br />\n Done" )
[1391]98
[1407]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)
[1391]106
Note: See TracBrowser for help on using the repository browser.