source: WAeUP_SRP/trunk/skins/waeup_student/delete_course_result.py @ 15185

Last change on this file since 15185 was 3125, checked in by joachim, 17 years ago

should avoid traceback #83 fcokene

File size: 1.4 KB
Line 
1## Script (Python) "delete_course_result"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=ids=[], REQUEST=None, action_after_reject=None, action_after_validate=''
8##title=
9##
10# $Id: delete_course_result.py 1557 2007-03-15 16:00:27Z joachim $
11"""
12FIXME: add docstring.
13"""
14
15from Products.CMFCore.utils import getToolByName
16from AccessControl import Unauthorized
17
18here = context
19from urllib import urlencode
20import logging
21logger = logging.getLogger('Skins.delete_course_result')
22mtool = context.portal_membership
23wf = context.portal_workflow
24member = mtool.getAuthenticatedMember()
25
26ret_url = here.absolute_url()
27
28message = ''
29student_id = context.getStudentId()
30if ids:
31    sid_level = "%s|%s" % (student_id,context.getId())
32    for key in ['%s|%s' % (sid_level,id) for id in ids]:
33        context.course_results.deleteRecord(key)
34    logger.info('%s deleted course result records %s for %s' % (member,ids,student_id))
35    message = 'psm_item(s)_deleted'
36else:
37    message = 'psm_select_at_least_one_document'
38
39args = {}
40args['portal_status_message'] = message
41
42if action_after_validate and same_type(action_after_validate,'abc'):
43    url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
44else:
45    url = context.absolute_url() + '?' + urlencode(args)
46if REQUEST is not None:
47    return REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.