source: WAeUP_SRP/trunk/skins/waeup_utilities/reindex_entry_mode.py @ 1400

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

gemaess Telefongespräch

File size: 2.3 KB
Line 
1## Script (Python) "reindex_entry_mode"
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: reindex_entry_mode.py 1328 2007-01-19 18:16:32Z joachim $
11"""
12reindex students_catalog entry_mode index
13"""
14request = context.REQUEST
15session = request.SESSION
16response = request.RESPONSE
17students = context.portal_url.getPortalObject().campus.students
18
19#def rwrite(s):
20#    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
21#    response.write(s)
22
23cat = context.students_catalog
24
25#ems = cat.uniqueValuesFor('entry_mode')
26#rwrite("entry_mode values: %s<br />\n" % (str(ems)))
27#for em in ems:
28#    res = cat(entry_mode = em)
29#    rwrite("entry_mode: %s = %d<br />\n" % (em,len(res)))
30
31sbrains = cat()
32count = 0
33lines = []
34
35for sb in sbrains:
36
37    em = context.getFromData_entry_mode(sb.id)
38    ec = 'x'
39    if em in ('UME','DE'):
40        ec = 'cup'
41        #cat.modifyRecord(id = sb.id,entry_mode = em)
42        lines.append('"%s","%s","","%s",""' % (ec,sb.id,sb.em))
43        #rwrite(ec +"--"+ sb.id +"--"+ em +"<br />")
44    else:
45        ret = context.returning_import(matric_no=sb.matric_no)
46        moe = ret[0].Mode_of_Entry
47        if moe in ('DE','DIRECT', 'DIRECT ENTRY',):
48            ec = 'de'
49            new_em = 'DE'
50        elif moe in ('UME','U.M.E', 'UNE',):
51            ec = 'ume'
52            new_em ="UME"
53        else:
54            ec = 'unk'
55            new_em = 'unknown'
56            moe = 'none'
57
58        #app = getattr(getattr(students,sb.id),'application',None)
59        #if app is not None:
60            #app.getContent().edit(mapping={'entry_mode': new_em})
61            #cat.modifyRecord(id = sb.id,entry_mode = new_em)
62        #else:
63            #cat.modifyRecord(id = sb.id,entry_mode = "")
64
65        lines.append('"%s","%s","%s","%s","%s"' % (ec,sb.id,sb.matric_no,moe,new_em))
66        #rwrite(ec +"--"+ sb.id +"--"+ em +"--"+ moe +"--"+ new_em +"<br />")
67
68setheader('Content-type','text/semicolon-seperated-values')
69setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"')
70setheader('Expires',  'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
71setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
72setheader('Cache-Control', 'post-check=0,pre-check=0')
73setheader('Pragma', 'no-cache') # HTTP/1.0
74return '\n'.join(lines)
Note: See TracBrowser for help on using the repository browser.