Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_151_resolve.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_151_resolve.py	(revision 1669)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_151_resolve.py	(revision 1669)
@@ -0,0 +1,114 @@
+## Script (Python) "ti_151_resolve"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+resolve ticket #151
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+import logging
+#>>>>>>>>>>>>>>>><
+logger = logging.getLogger('Skins.ti_151_resolve')
+logger.info('already done on 26.3.07 by joachim')
+return
+#<<<<<<<<<<<<<<<<<
+request = context.REQUEST
+session = request.SESSION
+response = request.RESPONSE
+setheader = request.RESPONSE.setHeader
+students = context.portal_url.getPortalObject().campus.students
+#from string import Template
+def rwrite(s):
+    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+    response.write(s)
+def getObject(outer,object):
+    if outer.hasObject(object):
+        return getattr(outer,object)
+    return None
+
+try:
+    from Products.AdvancedQuery import Eq, Between, Le,In
+    aq_students = context.students_catalog.evalAdvancedQuery
+except:
+    evalAdvancedQuery = None
+
+students_cat = context.students_catalog
+query = Eq('faculty','PSC') & Eq('department','PHY') & In('level',('300','400'))
+brains = aq_students(query)
+#brains = students_cat(faculty = 'PSC',department='PHY', level='400')
+total = 0
+count_ok = 0
+count_nosc = 0
+count_nolevel = 0
+count_level = 0
+count_renamed = 0
+#set_trace()
+#template = Template('"$count","$id","$course"')
+to_rename = []
+for student in brains:
+    student_dict = {}
+    for field in students_cat.schema():
+        student_dict[field] = getattr(student,field)
+    #s = template.substitute(student_dict,count=count,)
+    student_dict['total'] = total
+    while True:
+        if student.course == "BSCINP":
+            student_dict['message'] = "OK"
+            count_ok += 1
+            student_dict['sp_count'] = count_ok
+            s = '"%(total)d","%(sp_count)s","%(id)s","%(course)s","%(message)s",' % student_dict
+            break
+        student_dict['message'] = ""
+        student_obj = getObject(students,student.id)
+        if student_obj is None:
+            student_dict['message'] = "No student object"
+            break
+        study_course_obj = getObject(student_obj,'study_course')
+        if study_course_obj is None:
+            student_dict['message'] = "No study_course object"
+            count_nosc += 1
+            student_dict['sp_count'] = count_nosc
+            break
+        level_obj = getObject(student_obj,student.level)
+        if level_obj:
+            count_level += 1
+            study_course.manage_delObjects((student.level,))
+            student_dict['message'] = "Level deleted"
+            student_dict['sp_count'] = count_level
+        count_renamed += 1
+        to_rename.append(student.id)
+        student_dict['sp_count'] = count_renamed
+        student_dict['message'] = student_dict['message'] + "renamed to BSCINP"
+        study_course_doc = study_course_obj.getContent()
+        study_course_obj.edit(mapping = {'study_course': "BSCINP"})
+        total += 1
+        s = '"%(total)d","%(sp_count)s","%(id)s","%(course)s","%(message)s",' % student_dict
+        rwrite("%s<br />\r\n" %s)
+        break
+    total += 1
+    s = '"%(total)d","%(sp_count)s","%(id)s","%(course)s","%(message)s",' % student_dict
+    rwrite("%s<br />\r\n" %s)
+for sid in to_rename:
+    students_cat.modifyRecord(id = sid,course="BSCINP")
+sum = count_ok + count_nosc + count_nolevel + count_level    
+rwrite("total=%d,sum of below=%d,<br>\r\n correct study_course=%d<br>\r\n no study_course=%d<br>\r\n no level=%d<br>\r\n with level =%d,<br />\n Done" %
+        (total,
+         sum,
+         count_ok,
+         count_nosc,
+         count_nolevel,
+         count_level)
+         )
+
+logger.info("total=%d,sum=%d,ok=%d,no study_course=%d,no level=%d,with level =%d,\n Done" %
+             (total,sum,count_ok,count_nosc,count_nolevel,count_level))
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_165_resolve.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_165_resolve.py	(revision 1669)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_165_resolve.py	(revision 1669)
@@ -0,0 +1,98 @@
+## Script (Python) "ti_151_resolve"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+resolve ticket #151
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+import logging
+#>>>>>>>>>>>>>>>><
+logger = logging.getLogger('Skins.ti_165_resolve')
+#logger.info('already done on 26.3.07 by joachim')
+#return
+#<<<<<<<<<<<<<<<<<
+request = context.REQUEST
+session = request.SESSION
+response = request.RESPONSE
+setheader = request.RESPONSE.setHeader
+students = context.portal_url.getPortalObject().campus.students
+#from string import Template
+def rwrite(s):
+    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+    response.write("%s<br>\n\r" % s)
+def getObject(outer,object):
+    if outer.hasObject(object):
+        return getattr(outer,object)
+    return None
+
+try:
+    from Products.AdvancedQuery import Eq, Between, Le,In
+    aq_students = context.students_catalog.evalAdvancedQuery
+except:
+    evalAdvancedQuery = None
+
+students_cat = context.students_catalog
+pumeresults = context.portal_pumeresults
+de_students = students_cat(entry_mode = 'DE')
+found = 0
+not_found = 0
+for des in de_students:
+    if not des.jamb_reg_no.startswith('6'):
+        continue
+    pres = pumeresults(jamb_reg_no = des.jamb_reg_no)
+    if not pres:
+        student_obj = getObject(students,des.id)
+        if student_obj is None:
+            rwrite('%s with jamb_reg_no %s %s/%s/%s student object not found' % (des.id,
+                                                                            des.jamb_reg_no,
+                                                                            des.faculty,
+                                                                            des.department,
+                                                                            des.course,
+                                                                            ))
+            continue
+        pume_obj = getObject(student_obj,'pume')
+        if pume_obj is None:
+            rwrite('%s with jamb_reg_no %s %s/%s/%s pume object not found' % (des.id,
+                                                                            des.jamb_reg_no,
+                                                                            des.faculty,
+                                                                            des.department,
+                                                                            des.course,
+                                                                            ))
+            continue
+        pume_doc = pume_obj.getContent()
+        score = pume_doc.pume_tot_score
+        dict = {}
+        dict['student_id'] = des.id
+        dict['jamb_reg_no'] = des.jamb_reg_no
+        dict['course_code'] = des.course
+        dict['department'] = des.department
+        dict['faculty'] = des.faculty
+        dict['name'] = des.name
+        dict['score'] = score
+        dict['result_type'] = 'DE'
+        dict['sex'] = 'M'
+        if des.sex:
+            dict['sex'] = 'F'
+        s = '%(jamb_reg_no)s with student_id %(student_id)s not in pumeresults should be recreatet<br>\r\n'
+        s += 'Sex:%(sex)s,Name: %(name)s,Type:%(result_type)s<br>\n\r'
+        s += 'Studycourse: %(course_code)s,Faculty: %(faculty)s,Department: %(department)s,Score: %(score)s'
+        rwrite(s % (dict))
+            
+        not_found += 1
+        continue
+    found += 1
+    #rwrite('%s with jamb_reg_no %s found in pumeresults' % (des.id,des.jamb_reg_no))
+rwrite('%d found in pumeresults <br>%d not found in pumeresults<br>total in portal_pumeresults %d <br>' 
+        % (found,not_found,len(pumeresults())))
+    
