source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_165_resolve.py @ 9169

Last change on this file since 9169 was 1850, checked in by Henrik Bettermann, 17 years ago

search mode label 'beginning with' was wrong

  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1## Script (Python) "ti_151_resolve"
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: ti_165_resolve.py 1850 2007-06-03 16:54:55Z henrik $
11"""
12resolve ticket #151
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19import logging
20#>>>>>>>>>>>>>>>><
21logger = logging.getLogger('Skins.ti_165_resolve')
22#logger.info('already done on 26.3.07 by joachim')
23#return
24#<<<<<<<<<<<<<<<<<
25request = context.REQUEST
26session = request.SESSION
27response = request.RESPONSE
28setheader = request.RESPONSE.setHeader
29students = context.portal_url.getPortalObject().campus.students
30#from string import Template
31def rwrite(s):
32    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
33    response.write("%s<br>\n\r" % s)
34def getObject(outer,object):
35    if outer.hasObject(object):
36        return getattr(outer,object)
37    return None
38
39try:
40    from Products.AdvancedQuery import Eq, Between, Le,In
41    aq_students = context.students_catalog.evalAdvancedQuery
42except:
43    evalAdvancedQuery = None
44
45students_cat = context.students_catalog
46pumeresults = context.portal_pumeresults
47de_students = students_cat(entry_mode = 'de_ft')
48found = 0
49not_found = 0
50for des in de_students:
51    if not des.jamb_reg_no.startswith('6'):
52        continue
53    pres = pumeresults(jamb_reg_no = des.jamb_reg_no)
54    if not pres:
55        student_obj = getObject(students,des.id)
56        if student_obj is None:
57            rwrite('%s with jamb_reg_no %s %s/%s/%s student object not found' % (des.id,
58                                                                            des.jamb_reg_no,
59                                                                            des.faculty,
60                                                                            des.department,
61                                                                            des.course,
62                                                                            ))
63            continue
64        pume_obj = getObject(student_obj,'pume')
65        study_course_obj = getObject(student_obj,'study_course')
66        if pume_obj is None:
67            rwrite('%s with jamb_reg_no %s %s/%s/%s pume object not found' % (des.id,
68                                                                            des.jamb_reg_no,
69                                                                            des.faculty,
70                                                                            des.department,
71                                                                            des.course,
72                                                                            ))
73            continue
74           
75        dict = {}
76           
77        pume_doc = pume_obj.getContent()
78        if study_course_obj:
79            study_course_doc = study_course_obj.getContent()
80            course_code = study_course_doc.study_course
81            dict['course'] = course_code
82            dict['course_code_org'] = course_code
83           
84        score = pume_doc.pume_tot_score
85
86        dict['student_id'] = des.id
87        dict['jamb_reg_no'] = des.jamb_reg_no
88        dict['course_code'] = des.course
89        dict['department'] = des.department
90        dict['faculty'] = des.faculty
91        dict['name'] = des.name
92        dict['score'] = score
93        dict['result_type'] = 'de_ft'
94        dict['sex'] = 'M'
95        dict['status'] = 'Admitted'
96        if des.sex:
97            dict['sex'] = 'F'
98        s = '%(jamb_reg_no)s with student_id %(student_id)s not in pumeresults and is recreated<br>\r\n'
99        #s += 'Sex:%(sex)s,Name: %(name)s,Type:%(result_type)s<br>\n\r'
100        #s += 'Studycourse: %(course_code)s,Faculty: %(faculty)s,Department: %(department)s,Score: %(score)s'
101        rwrite(s % (dict))
102        pumeresults.addRecord(**dict)
103
104        not_found += 1
105        continue
106    found += 1
107    #rwrite('%s with jamb_reg_no %s found in pumeresults' % (des.id,des.jamb_reg_no))
108rwrite('%d found in pumeresults <br>%d not found in pumeresults<br>total in portal_pumeresults %d <br>'
109        % (found,not_found,len(pumeresults())))
110
Note: See TracBrowser for help on using the repository browser.