source: WAeUP_SRP/trunk/skins/waeup_utilities/fixLevelForNewStudents.py @ 1484

Last change on this file since 1484 was 1484, checked in by Henrik Bettermann, 18 years ago

fixed

  • Property svn:keywords set to Id
File size: 2.3 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=REQUEST
8##title=
9##
10# $Id: fixLevelForNewStudents.py 1484 2007-02-24 06:24:08Z henrik $
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
24mtool = context.portal_membership
25member = mtool.getAuthenticatedMember()
26retcat = context.returning_import
27rcat = context.results_import
28students_cat = context.students_catalog
29from Products.AdvancedQuery import Eq, Between, Le,In
30aq_students = students_cat.evalAdvancedQuery
31aq_portal = context.portal_catalog.evalAdvancedQuery
32students = context.portal_url.getPortalObject().campus.students
33
34count = 0
35##query = Eq('portal_type','Student') & In('review_state',('admitted',
36##                                                         'clearance_requested',
37##                                                         'cleared_and_validated',
38##                                                         'objection_raised',
39##                                                         )
40##res = aq_portal(query)
41query = Eq('level','100')
42res = aq_students(query)
43count = 0
44for sbrain in res:
45    student_obj = getattr(students,sbrain.id)
46    if sbrain.entry_mode == "":
47        if not student_obj.hasObject('application'):
48            rwrite("%s %s %s application not found <br />" % (sbrain.id,sbrain.entry_mode,level))
49            continue
50        app_doc = student_obj.application.getContent()
51        entry_mode = app_doc.entry_mode
52    else:
53        entry_mode = sbrain.entry_mode
54    if entry_mode == "DE":
55        level = "200"
56    else:
57        level = "100"
58    students_cat.modifyRecord(id=sbrain.id,
59                              level=level,
60                              entry_mode=entry_mode)
61    if not student_obj.hasObject('study_course'):
62        rwrite("%s %s %s study_course not found <br />" % (sbrain.id,sbrain.entry_mode,level))
63        continue
64    student_obj.study_course.getContent().edit(mapping={'current_level': level,
65                                                                       'current_verdict': 'N/A'})
66    count += 1
67    rwrite("%s: %s %s %s <br />" % (count,sbrain.id,entry_mode,level))
68
Note: See TracBrowser for help on using the repository browser.