## Script (Python) "search_pins"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST
##title=
##
# $Id: fixLevelForNewStudents.py 1486 2007-02-24 21:27:33Z joachim $
"""
list Students for ClearanceOfficers
"""
try:
from Products.zdb import set_trace
except:
def set_trace():
pass
request = context.REQUEST
session = request.SESSION
response = request.RESPONSE
setheader = request.RESPONSE.setHeader
import logging
logger = logging.getLogger('fixLevelForNewStudents')
def rwrite(s):
response.setHeader('Content-type','text/html; charset=ISO-8859-15')
response.write(s)
mtool = context.portal_membership
member = mtool.getAuthenticatedMember()
retcat = context.returning_import
rcat = context.results_import
students_cat = context.students_catalog
from Products.AdvancedQuery import Eq, Between, Le,In
aq_students = students_cat.evalAdvancedQuery
aq_portal = context.portal_catalog.evalAdvancedQuery
students = context.portal_url.getPortalObject().campus.students
count = 0
##query = Eq('portal_type','Student') & In('review_state',('admitted',
## 'clearance_requested',
## 'cleared_and_validated',
## 'objection_raised',
## )
##res = aq_portal(query)
query = Eq('level','100')
res = aq_students(query)
#set_trace()
count = 0
commit_count = 0
logger.info("started for %s students" % len(res))
for sbrain in res:
student_obj = getattr(students,sbrain.id)
if sbrain.entry_mode == "":
if not student_obj.hasObject('application'):
rwrite("%s %s %s application not found
" % (sbrain.id,sbrain.entry_mode,level))
continue
app_doc = student_obj.application.getContent()
entry_mode = app_doc.entry_mode
else:
entry_mode = sbrain.entry_mode
if entry_mode == "DE":
level = "200"
else:
level = "100"
students_cat.modifyRecord(id=sbrain.id,
level=level,
entry_mode=entry_mode)
if not student_obj.hasObject('study_course'):
rwrite("%s %s %s study_course not found
" % (sbrain.id,sbrain.entry_mode,level))
continue
student_obj.study_course.getContent().edit(mapping={'current_level': level,
'current_verdict': 'N/A'})
count += 1
commit_count += 1
if commit_count > 1000:
context.waeup_tool.doCommit()
logger.info("committing %s transactions total %s" % (commit_count,count))
commit_count = 0
rwrite("%s: %s %s %s
" % (count,sbrain.id,entry_mode,level))
rwrite("finished")
logger.info("finished %s students" % count)