## Script (Python) "folder_delete" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=ids=[], REQUEST=None ##title= ## # $Id: level_delete.py 2306 2007-10-03 17:22:43Z henrik $ """ delete a level, fix students review if necessary """ import logging logger = logging.getLogger('Skins.folder_delete') member_id = str(context.portal_membership.getAuthenticatedMember()) from Products.CMFCore.utils import getToolByName here = context ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type) meth_id = ti.queryMethodID('view', 'folder_contents') ret_url = here.absolute_url() + '/' + meth_id if ids: current_level = getattr(context.getContent(),'current_level','') current_level_deleted = (current_level in ids) student_id = context.getStudentId() student_state = context.getStudentReviewState(student_id=student_id) if current_level_deleted and student_state != "school_fee_paid": students_folder = context.portal_url.getPortalObject().campus.students student = getattr(students_folder,student_id) from Products.CMFCore.WorkflowCore import WorkflowException wftool = context.portal_workflow try: wftool.doActionFor(student,'reject_courses') except WorkflowException,E: pass #logger.info('%s WorkflowException %s for %s' % (member_id,E,student_id)) #return context.REQUEST.RESPONSE.redirect("%s" % context.absolute_url()) # for id in ids: # XXX has to be called from here since the workflow doesn't handle the # deletion yet # ob = getattr(here, id) # from Products.CPSCore.EventServiceTool import getPublicEventService # evtool = getPublicEventService(here) # evtool.notifyEvent('workflow_delete', ob, {}) here.manage_delObjects(ids) message = 'portal_status_message=psm_item(s)_deleted' else: message = 'portal_status_message=psm_select_at_least_one_document' if REQUEST is not None: return REQUEST.RESPONSE.redirect(ret_url + '?' + message)