## Script (Python) "delete_course_result" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=ids=[], REQUEST=None, action_after_reject=None, action_after_validate='' ##title= ## # $Id: delete_course_result.py 1557 2007-03-15 16:00:27Z joachim $ """ FIXME: add docstring. """ from Products.CMFCore.utils import getToolByName from AccessControl import Unauthorized here = context from urllib import urlencode import logging logger = logging.getLogger('Skins.delete_course_result') mtool = context.portal_membership wf = context.portal_workflow member = mtool.getAuthenticatedMember() ret_url = here.absolute_url() message = '' student_id = context.getStudentId() if ids: sid_level = "%s|%s" % (student_id,context.getId()) for key in ['%s|%s' % (sid_level,id) for id in ids]: context.course_results.deleteRecord(key) logger.info('%s deleted course result records %s for %s' % (member,ids,student_id)) message = 'psm_item(s)_deleted' else: message = 'psm_select_at_least_one_document' args = {} args['portal_status_message'] = message if action_after_validate: url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args) else: url = context.absolute_url() + '?' + urlencode(args) if REQUEST is not None: return REQUEST.RESPONSE.redirect(url)