[1387] | 1 | ## Script (Python) "search_pins" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
[1391] | 7 | ##parameters= |
---|
[1387] | 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: fixLevelFromResults.py 1409 2007-02-12 08:50:49Z henrik $ |
---|
| 11 | """ |
---|
| 12 | list Students for ClearanceOfficers |
---|
| 13 | """ |
---|
| 14 | |
---|
| 15 | request = context.REQUEST |
---|
| 16 | session = request.SESSION |
---|
| 17 | response = request.RESPONSE |
---|
[1391] | 18 | setheader = request.RESPONSE.setHeader |
---|
| 19 | |
---|
[1407] | 20 | def rwrite(s): |
---|
| 21 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
| 22 | response.write(s) |
---|
[1409] | 23 | |
---|
[1387] | 24 | wftool = context.portal_workflow |
---|
| 25 | mtool = context.portal_membership |
---|
| 26 | member = mtool.getAuthenticatedMember() |
---|
| 27 | roles = member.getRolesInContext(context) |
---|
| 28 | retcat = context.returning_import |
---|
| 29 | rcat = context.results_import |
---|
| 30 | scat = context.students_catalog |
---|
| 31 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
| 32 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
| 33 | students = context.portal_url.getPortalObject().campus.students |
---|
| 34 | |
---|
[1391] | 35 | |
---|
[1387] | 36 | if str(member) not in ('admin','joachim'): |
---|
[1391] | 37 | return |
---|
[1387] | 38 | count = 0 |
---|
[1401] | 39 | line_count = 0 |
---|
[1391] | 40 | lines = [] |
---|
[1387] | 41 | #from Products.zdb import set_trace;set_trace() |
---|
| 42 | res = scat() |
---|
| 43 | for sbrain in res: |
---|
[1391] | 44 | if str(sbrain.level) == '100': |
---|
| 45 | ec = "new" |
---|
| 46 | else: |
---|
| 47 | ec = "nor" |
---|
[1387] | 48 | erg = context.results_import(matric_no=sbrain.matric_no) |
---|
| 49 | if erg and erg[0].Level: |
---|
[1408] | 50 | #lc = "N" |
---|
[1407] | 51 | level_res = erg[0].Level |
---|
[1401] | 52 | everdict = erg[0].Verdict |
---|
[1407] | 53 | level_cc = context.getLevelFromResultsCosCode(erg) |
---|
[1408] | 54 | #if level_cc == 0: |
---|
| 55 | #lc = "-" |
---|
| 56 | #if "%d00" % level_cc != level_res: |
---|
| 57 | lc = 100*level_cc - int(level_res) |
---|
[1401] | 58 | verdict,elegible = context.getVerdict(everdict) |
---|
| 59 | if elegible: |
---|
[1408] | 60 | #lc = "S" |
---|
[1407] | 61 | level = "%d00" % (level_cc + 1) |
---|
[1409] | 62 | #context.students_catalog.modifyRecord(id = sbrain.id, |
---|
[1407] | 63 | # level="", |
---|
| 64 | # verdict = "") |
---|
[1387] | 65 | while True: |
---|
| 66 | student = getattr(students,sbrain.id,None) |
---|
[1388] | 67 | ec = "nos" |
---|
[1387] | 68 | if student is None: |
---|
| 69 | break |
---|
[1388] | 70 | ec = "nyr" |
---|
[1387] | 71 | study_course = getattr(student,"study_course", None) |
---|
| 72 | if study_course is None: |
---|
| 73 | break |
---|
[1407] | 74 | #study_course.getContent().edit(mapping = {'current_level':level, |
---|
| 75 | # 'current_verdict':verdict}) |
---|
[1409] | 76 | #context.students_catalog.modifyRecord(id = sbrain.id, |
---|
[1407] | 77 | # level=level, |
---|
| 78 | # verdict=verdict) |
---|
[1388] | 79 | ec = "reg" |
---|
[1387] | 80 | break |
---|
[1392] | 81 | |
---|
[1407] | 82 | #rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no +"--"+ old_level +"--"+ level +"<br />") |
---|
[1409] | 83 | s = '"%s","%s","%s","%s","%s","%s","%s","%s"' % (str(lc),ec, |
---|
[1401] | 84 | sbrain.id, |
---|
| 85 | sbrain.matric_no, |
---|
[1407] | 86 | level_res, |
---|
| 87 | level_cc, |
---|
[1401] | 88 | everdict, |
---|
[1407] | 89 | verdict) |
---|
| 90 | #lines.append(s) |
---|
[1388] | 91 | else: |
---|
[1407] | 92 | #rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no + "<br />") |
---|
| 93 | s = '"","%s","%s","%s","",""' % (ec,sbrain.id,sbrain.matric_no) |
---|
| 94 | #lines.append(s) |
---|
[1409] | 95 | |
---|
[1407] | 96 | rwrite("%s<br />" %s) |
---|
[1388] | 97 | # count += 1 |
---|
| 98 | # if count > 60: |
---|
[1401] | 99 | # line_count += 1 |
---|
| 100 | # rwrite("<br />\n%3d " % line_count) |
---|
[1388] | 101 | # count = 0 |
---|
| 102 | |
---|
[1407] | 103 | rwrite("<br />\n Done" ) |
---|
[1391] | 104 | |
---|
[1407] | 105 | ##setheader('Content-type','text/semicolon-seperated-values') |
---|
| 106 | ##setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"') |
---|
| 107 | ##setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past |
---|
| 108 | ##setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 |
---|
| 109 | ##setheader('Cache-Control', 'post-check=0,pre-check=0') |
---|
| 110 | ##setheader('Pragma', 'no-cache') # HTTP/1.0 |
---|
| 111 | ##return '\n'.join(lines) |
---|
[1391] | 112 | |
---|