## Script (Python) "search_pins"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
# $Id: fixLevelFromResults.py 1401 2007-02-08 18:08:38Z joachim $
"""
list Students for ClearanceOfficers
"""
request = context.REQUEST
session = request.SESSION
response = request.RESPONSE
setheader = request.RESPONSE.setHeader
#def rwrite(s):
# response.setHeader('Content-type','text/html; charset=ISO-8859-15')
# response.write(s)
wftool = context.portal_workflow
mtool = context.portal_membership
member = mtool.getAuthenticatedMember()
roles = member.getRolesInContext(context)
retcat = context.returning_import
rcat = context.results_import
scat = context.students_catalog
from Products.AdvancedQuery import Eq, Between, Le,In
aq_students = context.students_catalog.evalAdvancedQuery
students = context.portal_url.getPortalObject().campus.students
if str(member) not in ('admin','joachim'):
return
count = 0
line_count = 0
lines = []
#from Products.zdb import set_trace;set_trace()
res = scat()
for sbrain in res:
old_level = str(sbrain.level)
if str(sbrain.level) == '100':
ec = "new"
else:
ec = "nor"
erg = context.results_import(matric_no=sbrain.matric_no)
lc = 'u'
if erg and erg[0].Level:
lc = "e" # code for level status u = unset
level = erg[0].Level
everdict = erg[0].Verdict
lnr = context.getLevelFromResultsCosCode(erg)
if lnr == 0:
lc = "-"
if "%d00" % lnr != level:
lc = "!"
verdict,elegible = context.getVerdict(everdict)
if elegible:
lc = "+"
level = "%d00" % (lnr + 1)
context.students_catalog.modifyRecord(id = sbrain.id,
level="",
verdict = "")
while True:
student = getattr(students,sbrain.id,None)
ec = "nos"
if student is None:
break
ec = "nyr"
study_course = getattr(student,"study_course", None)
if study_course is None:
break
study_course.getContent().edit(mapping = {'current_level':level,
'current_verdict':verdict})
context.students_catalog.modifyRecord(id = sbrain.id,
level=level,
verdict=verdict)
ec = "reg"
break
# rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no +"--"+ old_level +"--"+ level +"
")
lines.append('"%s %s","%s","%s","%s","%s","%s","%s"' % (lc,ec,
sbrain.id,
sbrain.matric_no,
old_level,
level,
everdict,
verdict))
else:
# rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no + "
")
lines.append('"%s","%s","%s","",""' % (ec,sbrain.id,sbrain.matric_no))
# count += 1
# if count > 60:
# line_count += 1
# rwrite("
\n%3d " % line_count)
# count = 0
#rwrite("
\n Done" )
setheader('Content-type','text/semicolon-seperated-values')
setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"')
setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
setheader('Cache-Control', 'post-check=0,pre-check=0')
setheader('Pragma', 'no-cache') # HTTP/1.0
return '\n'.join(lines)