source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_182_resolve.py @ 17977

Last change on this file since 17977 was 1672, checked in by joachim, 18 years ago

utility to fix #182

  • Property svn:keywords set to Id
File size: 4.4 KB
RevLine 
[1672]1## Script (Python) "getNewStudentStatistics"
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_182_resolve.py 1672 2007-04-07 16:31:30Z joachim $
11"""
12resolve ticket #182
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19import logging
20#>>>>>>>>>>>>>>>><
21logger = logging.getLogger('Skins.ti_182_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 intersect(m,n):
32    return [i for i in m if i in n]
33
34def rwrite(s):
35    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
36    response.write("%s<br>\n\r" % s)
37def getObject(outer,object):
38    if outer.hasObject(object):
39        return getattr(outer,object)
40    return None
41try:
42    from Products.AdvancedQuery import Eq, Between, Le,In, Ge,MatchRegexp
43    aq_portal = context.portal_catalog.evalAdvancedQuery
44    aq_students = context.students_catalog.evalAdvancedQuery
45except:
46    evalAdvancedQuery = None
47
48
49#freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE'))
50#total_new = aq_students(freshquery)
51##query = In('review_state',('cleared_and_validated',
52##                           'school_fee_paid',
53##                           'courses_registered',
54##                           'courses_validated'))
55##cleared = aq_portal(query)
56##rwrite("Cleared and beyond students: %d" % len(cleared))
57##cleared_ids = [s.getId for s in cleared]
58newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*')
59new_students = aq_portal(newquery)
60new_ids = [r.getPath().split('/')[-2] for r in new_students]
61rwrite("New students: %d" % len(new_ids))
62#diff_new_cleared = [i for i in new_ids if i not in cleared_ids] 
63#diff_cleared_new = [i for i in cleared_ids if i not in new_ids] 
64##special_states =  ('admitted',
65##                   'clearance_pin_entered',
66##                   'clearance_requested',
67##                   'cleared_and_validated',
68##                   'objection_raised',
69##                   )
70##special_query = In('review_state',special_states)
71##special = aq_portal(special_query)
72##special_ids = [s.getId for s in special]
73##rwrite("New special students: %d" % len(special_ids))
74admitted_query = Eq('review_state','admitted')
75admitted = aq_portal(admitted_query)
76admitted_ids = [s.getId for s in admitted]
77rwrite("Admitted students: %d" % len(admitted_ids))
78##faculties = context.portal_catalog(portal_type="Faculty")
79##fac_ids = [f.getId for f in faculties]
80##fac_query = In('faculty',fac_ids)
81##faculties_students = aq_students(fac_query)
82##faculties_student_ids = [s.id for s in faculties_students]
83##set_trace()
84count = 0
85for sid in admitted_ids:
86    if sid not in new_ids:
87        if not count:
88            rwrite('Students with review_state admitted and jamb_reg_no not beginning with 6')
89        count += 1
90        erg = context.students_catalog(id=sid)
91        if not erg:
92            set_trace()
93            continue
94        student = erg[0]
95        dict = context.getFormattedStudentEntry(student)
96        dict['count'] = count
97        dict['review_state'] = 'admitted'
98        rwrite('"%(count)d","%(id)s","%(name)s","%(jamb_reg_no)s","%(faculty)s","%(entry_mode)s,"%(review_state)s,"%(level)s",' % dict)
99       
100##retcount = 0
101##count = 0
102##newc = 0
103###set_trace()
104##for student in cleared:
105##    erg = context.students_catalog(id=student.getId)
106##    if not erg:
107##        set_trace()
108##        continue
109##    if not erg[0].jamb_reg_no.startswith('6'):
110##        retcount += 1
111##        continue
112##    newc += 1
113##    if not student.getId in special_ids:
114##        count += 1
115####        dict = context.getFormattedStudentEntry(student)
116####        dict['review_state'] = 'unknown'
117####        dict['count'] = count
118####        res = context.portal_catalog(portal_type='Student',id = student.getId)
119####        if res:
120####            rs = dict['review_state'] = res[0].review_state
121####            rwrite('"%(count)d","%(id)s","%(name)s","%(jamb_reg_no)s","%(matric_no)s","%(entry_mode)s,"%(level)s","%(review_state)s"' % dict)
122##rwrite("Cleared not in special: %d" % count)
123##rwrite("Returning students: %d" % retcount)
124##rwrite("New cleared students: %d" % newc)
125rwrite("Finished")
126
Note: See TracBrowser for help on using the repository browser.