[1571] | 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 |
---|
[1590] | 7 | ##parameters=ids=[], REQUEST=None, action_after_reject=None, action_after_validate=None |
---|
[1571] | 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: delete_course_result.py 1557 2007-03-15 16:00:27Z joachim $ |
---|
| 11 | """ |
---|
| 12 | FIXME: add docstring. |
---|
| 13 | """ |
---|
| 14 | |
---|
| 15 | from Products.CMFCore.utils import getToolByName |
---|
[1613] | 16 | from AccessControl import Unauthorized |
---|
| 17 | |
---|
[1571] | 18 | here = context |
---|
[1590] | 19 | from urllib import urlencode |
---|
[1571] | 20 | import logging |
---|
| 21 | logger = logging.getLogger('Skins.delete_course_result') |
---|
| 22 | mtool = context.portal_membership |
---|
| 23 | member = mtool.getAuthenticatedMember() |
---|
| 24 | |
---|
| 25 | ret_url = here.absolute_url() |
---|
| 26 | |
---|
| 27 | message = '' |
---|
| 28 | if ids: |
---|
| 29 | real_ids = [] |
---|
| 30 | for id in ids: |
---|
| 31 | if context.hasObject(id): |
---|
| 32 | real_ids.append(id) |
---|
| 33 | if real_ids: |
---|
[1613] | 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' |
---|
[1571] | 41 | else: |
---|
[1591] | 42 | message = 'psm_select_at_least_one_document' |
---|
[1600] | 43 | |
---|
[1591] | 44 | args = {} |
---|
[1590] | 45 | args['portal_status_message'] = message |
---|
[1606] | 46 | |
---|
| 47 | if action_after_validate: |
---|
| 48 | url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args) |
---|
| 49 | else: |
---|
| 50 | url = context.absolute_url() + '?' + urlencode(args) |
---|
[1571] | 51 | if REQUEST is not None: |
---|
[1600] | 52 | return REQUEST.RESPONSE.redirect(url) |
---|