[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 | """ |
---|
| 12 | reindex students_catalog entry_mode index |
---|
| 13 | """ |
---|
[1380] | 14 | request = context.REQUEST |
---|
| 15 | session = request.SESSION |
---|
| 16 | response = request.RESPONSE |
---|
| 17 | students = context.portal_url.getPortalObject().campus.students |
---|
[1392] | 18 | |
---|
| 19 | #def rwrite(s): |
---|
| 20 | # response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
| 21 | # response.write(s) |
---|
| 22 | |
---|
[1334] | 23 | cat = context.students_catalog |
---|
[1392] | 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 | |
---|
[1334] | 31 | sbrains = cat() |
---|
[1380] | 32 | count = 0 |
---|
[1392] | 33 | lines = [] |
---|
[1389] | 34 | |
---|
[1334] | 35 | for sb in sbrains: |
---|
[1392] | 36 | |
---|
[1380] | 37 | em = context.getFromData_entry_mode(sb.id) |
---|
| 38 | ec = 'x' |
---|
| 39 | if em in ('UME','DE'): |
---|
[1392] | 40 | ec = 'cup' |
---|
[1389] | 41 | #cat.modifyRecord(id = sb.id,entry_mode = em) |
---|
[1392] | 42 | lines.append('"%s","%s","","%s",""' % (ec,sb.id,sb.em)) |
---|
| 43 | #rwrite(ec +"--"+ sb.id +"--"+ em +"<br />") |
---|
[1389] | 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',): |
---|
[1392] | 51 | ec = 'ume' |
---|
[1389] | 52 | new_em ="UME" |
---|
| 53 | else: |
---|
[1392] | 54 | ec = 'unk' |
---|
[1389] | 55 | new_em = 'unknown' |
---|
| 56 | moe = 'none' |
---|
[1334] | 57 | |
---|
[1389] | 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: |
---|
[1392] | 63 | #cat.modifyRecord(id = sb.id,entry_mode = "") |
---|
[1389] | 64 | |
---|
[1392] | 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 | |
---|
| 68 | setheader('Content-type','text/semicolon-seperated-values') |
---|
| 69 | setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"') |
---|
| 70 | setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past |
---|
| 71 | setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 |
---|
| 72 | setheader('Cache-Control', 'post-check=0,pre-check=0') |
---|
| 73 | setheader('Pragma', 'no-cache') # HTTP/1.0 |
---|
| 74 | return '\n'.join(lines) |
---|