[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 |
---|
| 7 | ##parameters=REQUEST |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: fixLevelFromResults.py 1388 2007-02-04 08:48:18Z henrik $ |
---|
| 11 | """ |
---|
| 12 | list Students for ClearanceOfficers |
---|
| 13 | """ |
---|
| 14 | |
---|
| 15 | request = REQUEST |
---|
| 16 | request = context.REQUEST |
---|
| 17 | session = request.SESSION |
---|
| 18 | response = request.RESPONSE |
---|
| 19 | def rwrite(s): |
---|
| 20 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
| 21 | #response.setHeader('Content-length','%d' % (len(s))) |
---|
| 22 | #response.setStatus('OK') |
---|
| 23 | response.write(s) |
---|
| 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 | |
---|
| 35 | if str(member) not in ('admin','joachim'): |
---|
| 36 | return |
---|
| 37 | count = 0 |
---|
| 38 | lc = 1 |
---|
| 39 | #from Products.zdb import set_trace;set_trace() |
---|
| 40 | res = scat() |
---|
| 41 | for sbrain in res: |
---|
[1388] | 42 | ec = "nor" |
---|
[1387] | 43 | erg = context.results_import(matric_no=sbrain.matric_no) |
---|
| 44 | if erg and erg[0].Level: |
---|
| 45 | ec = "e" |
---|
| 46 | level = erg[0].Level |
---|
| 47 | for e in erg: |
---|
| 48 | ec = "E" |
---|
| 49 | if level != e.Level: |
---|
| 50 | ec = "%s:%s!=%s<br />\n" % (sbrain.matric_no,level,e.Level) |
---|
| 51 | level = "%d" % (int(level) + 100) |
---|
[1388] | 52 | |
---|
| 53 | # würde ich an dieser Stelle nicht machen (siehe unten) |
---|
| 54 | #context.students_catalog.modifyRecord(id = sbrain.id, level=level) |
---|
| 55 | |
---|
[1387] | 56 | while True: |
---|
| 57 | student = getattr(students,sbrain.id,None) |
---|
[1388] | 58 | ec = "nos" |
---|
[1387] | 59 | if student is None: |
---|
| 60 | break |
---|
[1388] | 61 | ec = "nyr" |
---|
[1387] | 62 | study_course = getattr(student,"study_course", None) |
---|
| 63 | if study_course is None: |
---|
| 64 | break |
---|
| 65 | study_course.getContent().edit(mapping = {'current_level':level}) |
---|
[1388] | 66 | |
---|
| 67 | #dies ist der richtige Platz |
---|
| 68 | context.students_catalog.modifyRecord(id = sbrain.id, level=level) |
---|
| 69 | |
---|
| 70 | ec = "reg" |
---|
[1387] | 71 | break |
---|
[1388] | 72 | if sbrain.level: |
---|
| 73 | old_level = str(sbrain.level) |
---|
| 74 | else: |
---|
| 75 | old_level = 'non' |
---|
| 76 | rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no +"--"+ old_level +"--"+ level +"<br />") |
---|
| 77 | |
---|
| 78 | else: |
---|
| 79 | rwrite(ec +"--"+ sbrain.id +"--"+ sbrain.matric_no + "<br />") |
---|
| 80 | # count += 1 |
---|
| 81 | # if count > 60: |
---|
| 82 | # lc += 1 |
---|
| 83 | # rwrite("<br />\n%3d " % lc) |
---|
| 84 | # count = 0 |
---|
[1387] | 85 | rwrite("<br />\n Done" ) |
---|
[1388] | 86 | |
---|