[1508] | 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: removeResults2.py 1508 2007-02-27 14:32:20Z joachim $ |
---|
| 11 | """ |
---|
| 12 | remove results according to faculty-prefix |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
| 15 | logger = logging.getLogger('removeResults2') |
---|
| 16 | |
---|
| 17 | request = REQUEST |
---|
| 18 | response = request.RESPONSE |
---|
| 19 | try: |
---|
| 20 | from Products.zdb import set_trace |
---|
| 21 | except: |
---|
| 22 | def set_trace(): |
---|
| 23 | pass |
---|
| 24 | |
---|
| 25 | def rwrite(s): |
---|
| 26 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
| 27 | #response.setHeader('Content-length','%d' % (len(s))) |
---|
| 28 | #response.setStatus('OK') |
---|
| 29 | response.write(s) |
---|
| 30 | |
---|
| 31 | faculties_to_del = ('SCN','LSC','PSC','PHA') |
---|
| 32 | |
---|
| 33 | mtool = context.portal_membership |
---|
| 34 | member = mtool.getAuthenticatedMember() |
---|
| 35 | rcat = context.results_import |
---|
| 36 | scat = context.students_catalog |
---|
| 37 | if str(member) not in ('admin','joachim'): |
---|
| 38 | return |
---|
| 39 | rwrite("start") |
---|
| 40 | to_del = [] |
---|
| 41 | for r in rcat(): |
---|
| 42 | if r.matric_no[:3] in faculties_to_del: |
---|
| 43 | to_del.append(r.key) |
---|
| 44 | rwrite(r.matric_no + " " + r.Level +" " + r.CosCode + "<br />") |
---|
| 45 | logger.info('"%s", "start to delete %s results"' % (member,len(to_del))) |
---|
| 46 | for uid in to_del: |
---|
| 47 | rcat.deleteRecord(uid) |
---|
| 48 | logger.info('"%s", "finished with deletion of %s results"' % (member,len(to_del))) |
---|
| 49 | rwrite("Done") |
---|
| 50 | |
---|