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 1669 2007-04-04 06:31:52Z joachim $ |
---|
11 | """ |
---|
12 | resolve ticket #151 |
---|
13 | """ |
---|
14 | try: |
---|
15 | from Products.zdb import set_trace |
---|
16 | except: |
---|
17 | def set_trace(): |
---|
18 | pass |
---|
19 | import logging |
---|
20 | #>>>>>>>>>>>>>>>>< |
---|
21 | logger = logging.getLogger('Skins.ti_165_resolve') |
---|
22 | #logger.info('already done on 26.3.07 by joachim') |
---|
23 | #return |
---|
24 | #<<<<<<<<<<<<<<<<< |
---|
25 | request = context.REQUEST |
---|
26 | session = request.SESSION |
---|
27 | response = request.RESPONSE |
---|
28 | setheader = request.RESPONSE.setHeader |
---|
29 | students = context.portal_url.getPortalObject().campus.students |
---|
30 | #from string import Template |
---|
31 | def rwrite(s): |
---|
32 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
33 | response.write("%s<br>\n\r" % s) |
---|
34 | def getObject(outer,object): |
---|
35 | if outer.hasObject(object): |
---|
36 | return getattr(outer,object) |
---|
37 | return None |
---|
38 | |
---|
39 | try: |
---|
40 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
41 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
42 | except: |
---|
43 | evalAdvancedQuery = None |
---|
44 | |
---|
45 | students_cat = context.students_catalog |
---|
46 | pumeresults = context.portal_pumeresults |
---|
47 | de_students = students_cat(entry_mode = 'DE') |
---|
48 | found = 0 |
---|
49 | not_found = 0 |
---|
50 | for 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 | if pume_obj is None: |
---|
66 | rwrite('%s with jamb_reg_no %s %s/%s/%s pume object not found' % (des.id, |
---|
67 | des.jamb_reg_no, |
---|
68 | des.faculty, |
---|
69 | des.department, |
---|
70 | des.course, |
---|
71 | )) |
---|
72 | continue |
---|
73 | pume_doc = pume_obj.getContent() |
---|
74 | score = pume_doc.pume_tot_score |
---|
75 | dict = {} |
---|
76 | dict['student_id'] = des.id |
---|
77 | dict['jamb_reg_no'] = des.jamb_reg_no |
---|
78 | dict['course_code'] = des.course |
---|
79 | dict['department'] = des.department |
---|
80 | dict['faculty'] = des.faculty |
---|
81 | dict['name'] = des.name |
---|
82 | dict['score'] = score |
---|
83 | dict['result_type'] = 'DE' |
---|
84 | dict['sex'] = 'M' |
---|
85 | if des.sex: |
---|
86 | dict['sex'] = 'F' |
---|
87 | s = '%(jamb_reg_no)s with student_id %(student_id)s not in pumeresults should be recreatet<br>\r\n' |
---|
88 | s += 'Sex:%(sex)s,Name: %(name)s,Type:%(result_type)s<br>\n\r' |
---|
89 | s += 'Studycourse: %(course_code)s,Faculty: %(faculty)s,Department: %(department)s,Score: %(score)s' |
---|
90 | rwrite(s % (dict)) |
---|
91 | |
---|
92 | not_found += 1 |
---|
93 | continue |
---|
94 | found += 1 |
---|
95 | #rwrite('%s with jamb_reg_no %s found in pumeresults' % (des.id,des.jamb_reg_no)) |
---|
96 | rwrite('%d found in pumeresults <br>%d not found in pumeresults<br>total in portal_pumeresults %d <br>' |
---|
97 | % (found,not_found,len(pumeresults()))) |
---|
98 | |
---|