source: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/removeResults2.py @ 15344

Last change on this file since 15344 was 1596, checked in by joachim, 18 years ago

merged changes from trunk to joachim-event-branch

  • Property svn:keywords set to Id
File size: 1.2 KB
RevLine 
[1596]1## Script (Python) "removeResults2"
[1508]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 1596 2007-03-19 21:45:44Z joachim $
11"""
12remove results according to faculty-prefix
13"""
14import logging
[1596]15logger = logging.getLogger('Skins.removeResults2')
[1508]16
17request = REQUEST
18response = request.RESPONSE
19try:
20    from Products.zdb import set_trace
21except:
22    def set_trace():
23        pass
24
25def 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
31faculties_to_del = ('SCN','LSC','PSC','PHA')
32
33mtool = context.portal_membership
34member = mtool.getAuthenticatedMember()
35rcat = context.results_import
36scat = context.students_catalog
37if str(member) not in ('admin','joachim'):
38    return
39rwrite("start")
40to_del = []
41for 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 />")
[1596]45logger.info('%s starts to delete %s results' % (member,len(to_del)))
[1508]46for uid in to_del:
47    rcat.deleteRecord(uid)
[1596]48logger.info('%s finished deletion of %s results' % (member,len(to_del)))
[1508]49rwrite("Done")
50
Note: See TracBrowser for help on using the repository browser.