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

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

Protolollierung geändert

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