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

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

Protolollierung geändert

File size: 2.5 KB
RevLine 
[1334]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"""
[1380]14request = context.REQUEST
15session = request.SESSION
16response = request.RESPONSE
[1408]17setheader = request.RESPONSE.setHeader
[1380]18students = context.portal_url.getPortalObject().campus.students
[1392]19
[1408]20def rwrite(s):
21    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
22    response.write(s)
[1392]23
[1334]24cat = context.students_catalog
[1392]25
[1408]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)))
[1392]31
[1334]32sbrains = cat()
[1380]33count = 0
[1392]34lines = []
[1389]35
[1334]36for sb in sbrains:
[1392]37
[1380]38    em = context.getFromData_entry_mode(sb.id)
39    ec = 'x'
[1408]40    level_cat = sb.level
[1380]41    if em in ('UME','DE'):
[1392]42        ec = 'cup'
[1389]43        #cat.modifyRecord(id = sb.id,entry_mode = em)
[1408]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)
[1389]47    else:
48        ret = context.returning_import(matric_no=sb.matric_no)
49        moe = ret[0].Mode_of_Entry
[1408]50       
[1389]51        if moe in ('DE','DIRECT', 'DIRECT ENTRY',):
52            ec = 'de'
53            new_em = 'DE'
54        elif moe in ('UME','U.M.E', 'UNE',):
[1392]55            ec = 'ume'
[1389]56            new_em ="UME"
57        else:
[1392]58            ec = 'unk'
[1389]59            new_em = 'unknown'
60            moe = 'none'
[1334]61
[1389]62        #app = getattr(getattr(students,sb.id),'application',None)
63        #if app is not None:
[1408]64        #    app.getContent().edit(mapping={'entry_mode': new_em})
65        #    cat.modifyRecord(id = sb.id,entry_mode = new_em)
[1389]66        #else:
[1408]67        #    cat.modifyRecord(id = sb.id,entry_mode = "")
[1389]68
[1408]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)
[1392]72
[1408]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.