source: WAeUP_SRP/trunk/skins/waeup_utilities/deleteResultByKey.py @ 17935

Last change on this file since 17935 was 2328, checked in by Henrik Bettermann, 17 years ago

improve application forms

File size: 1.2 KB
Line 
1## Script (Python) "deleteResultByKey"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST,key=None
8##title=
9##
10# $Id: deleteStudentByMatricNo.py 1567 2007-03-17 08:34:51Z henrik $
11"""
12"""
13import logging
14logger = logging.getLogger('Skins.deleteResultByKey')
15
16request = REQUEST
17wftool = context.portal_workflow
18mtool = context.portal_membership
19member = mtool.getAuthenticatedMember()
20roles = member.getRolesInContext(context)
21stdir = context.portal_directories.students
22st_cat = context.students_catalog
23ret_imp = context.returning_import
24res_imp = context.results_import
25students = context.portal_url.getPortalObject().campus.students
26if str(member) not in ('admin','joachim','med','despej') or key is None:
27    return 'You are not allowed to execute this command!'
28
29output = []
30
31# remove from results_import
32
33res_deleted = []
34res_res = res_imp(key=key)
35if len(res_res) > 0:
36    for r in res_res:
37        res_imp.deleteRecord(r.key)
38        res_deleted.append(r.key)
39    msg = "%s deleted result %s from results_import" % (member,',\n'.join(res_deleted))
40else:
41    msg = "No results %s to delete from results_import" % key
42output.append(msg)
43logger.info(msg)
44
45
46return "\n".join(output)
47
Note: See TracBrowser for help on using the repository browser.