source: WAeUP_SRP/branches/uli/skins/waeup_student/delete_course_result.py @ 9819

Last change on this file since 9819 was 1653, checked in by uli, 18 years ago

Incorporated changeset 1593:1652 of trunk into uli-branch.

File size: 1.5 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=None
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
23member = mtool.getAuthenticatedMember()
24
25ret_url = here.absolute_url()
26
27message = ''
28if ids:
29    real_ids = []
30    for id in ids:
31        if context.hasObject(id):
32            real_ids.append(id)
33    if real_ids:
34        try:
35            context.manage_delObjects(real_ids)
36            logger.info('%s deleted StudentCourseResult object %s for %s' % (member,id,context.getStudentId()))
37            message = 'psm_item(s)_deleted'
38        except Unauthorized:
39            logger.info('%s has no permission to delete StudentCourseResult objects for %s' % (member,context.getStudentId()))
40            message = 'no item(s) deleted'
41else:
42    message = 'psm_select_at_least_one_document'
43
44args = {}
45args['portal_status_message'] = message
46
47if action_after_validate:
48    url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
49else:
50    url = context.absolute_url() + '?' + urlencode(args)
51if REQUEST is not None:
52    return REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.