[2138] | 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 | """ |
---|
| 12 | delete a level, fix students review if necessary |
---|
| 13 | """ |
---|
| 14 | |
---|
| 15 | import logging |
---|
| 16 | logger = logging.getLogger('Skins.folder_delete') |
---|
| 17 | member_id = str(context.portal_membership.getAuthenticatedMember()) |
---|
| 18 | |
---|
| 19 | from Products.CMFCore.utils import getToolByName |
---|
| 20 | here = context |
---|
| 21 | |
---|
| 22 | ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type) |
---|
| 23 | meth_id = ti.queryMethodID('view', 'folder_contents') |
---|
| 24 | ret_url = here.absolute_url() + '/' + meth_id |
---|
| 25 | |
---|
| 26 | if 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: |
---|
[2306] | 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()) |
---|
[2138] | 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' |
---|
| 51 | else: |
---|
| 52 | message = 'portal_status_message=psm_select_at_least_one_document' |
---|
| 53 | |
---|
| 54 | if REQUEST is not None: |
---|
| 55 | return REQUEST.RESPONSE.redirect(ret_url + '?' + message) |
---|