source: WAeUP_SRP/base/skins/waeup_student/level_delete.py @ 2329

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

pass (do not return) if doActionFor fails

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1## Script (Python) "folder_delete"
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
8##title=
9##
10# $Id: level_delete.py 2306 2007-10-03 17:22:43Z henrik $
11"""
12delete a level, fix students review if necessary
13"""
14
15import logging
16logger = logging.getLogger('Skins.folder_delete')
17member_id = str(context.portal_membership.getAuthenticatedMember())
18
19from Products.CMFCore.utils import getToolByName
20here = context
21
22ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type)
23meth_id = ti.queryMethodID('view', 'folder_contents')
24ret_url = here.absolute_url() + '/' + meth_id
25
26if ids:
27    current_level = getattr(context.getContent(),'current_level','')
28    current_level_deleted = (current_level in ids)
29    student_id = context.getStudentId()
30    student_state = context.getStudentReviewState(student_id=student_id)
31    if current_level_deleted and student_state != "school_fee_paid":
32        students_folder = context.portal_url.getPortalObject().campus.students
33        student = getattr(students_folder,student_id)
34        from Products.CMFCore.WorkflowCore import WorkflowException
35        wftool = context.portal_workflow
36        try:
37            wftool.doActionFor(student,'reject_courses')
38        except WorkflowException,E:
39            pass
40            #logger.info('%s WorkflowException %s for %s' % (member_id,E,student_id))
41            #return context.REQUEST.RESPONSE.redirect("%s" % context.absolute_url())
42    # for id in ids:
43    #     XXX has to be called from here since the workflow doesn't handle the
44    #     deletion yet
45    #     ob = getattr(here, id)
46    #     from Products.CPSCore.EventServiceTool import getPublicEventService
47    #     evtool = getPublicEventService(here)
48    #     evtool.notifyEvent('workflow_delete', ob, {})
49    here.manage_delObjects(ids)
50    message = 'portal_status_message=psm_item(s)_deleted'
51else:
52    message = 'portal_status_message=psm_select_at_least_one_document'
53
54if REQUEST is not None:
55    return REQUEST.RESPONSE.redirect(ret_url + '?' + message)
Note: See TracBrowser for help on using the repository browser.