[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 2138 2007-08-21 09:19:10Z joachim $ |
---|
| 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 | #if context.portal_type == "University": |
---|
| 23 | # here = context.academics |
---|
| 24 | |
---|
| 25 | ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type) |
---|
| 26 | meth_id = ti.queryMethodID('view', 'folder_contents') |
---|
| 27 | ret_url = here.absolute_url() + '/' + meth_id |
---|
| 28 | |
---|
| 29 | if ids: |
---|
| 30 | current_level = getattr(context.getContent(),'current_level','') |
---|
| 31 | current_level_deleted = (current_level in ids) |
---|
| 32 | student_id = context.getStudentId() |
---|
| 33 | student_state = context.getStudentReviewState(student_id=student_id) |
---|
| 34 | if current_level_deleted and student_state != "school_fee_paid": |
---|
| 35 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
| 36 | student = getattr(students_folder,student_id) |
---|
| 37 | from Products.CMFCore.WorkflowCore import WorkflowException |
---|
| 38 | wftool = context.portal_workflow |
---|
| 39 | try: |
---|
| 40 | wftool.doActionFor(student,'reject_courses') |
---|
| 41 | except WorkflowException,E: |
---|
| 42 | logger.info('%s WorkflowException %s for %s' % (member_id,E,student_id)) |
---|
| 43 | return request.RESPONSE.redirect("%s" % context.absolute_url()) |
---|
| 44 | # for id in ids: |
---|
| 45 | # XXX has to be called from here since the workflow doesn't handle the |
---|
| 46 | # deletion yet |
---|
| 47 | # ob = getattr(here, id) |
---|
| 48 | # from Products.CPSCore.EventServiceTool import getPublicEventService |
---|
| 49 | # evtool = getPublicEventService(here) |
---|
| 50 | # evtool.notifyEvent('workflow_delete', ob, {}) |
---|
| 51 | here.manage_delObjects(ids) |
---|
| 52 | message = 'portal_status_message=psm_item(s)_deleted' |
---|
| 53 | else: |
---|
| 54 | message = 'portal_status_message=psm_select_at_least_one_document' |
---|
| 55 | |
---|
| 56 | if REQUEST is not None: |
---|
| 57 | return REQUEST.RESPONSE.redirect(ret_url + '?' + message) |
---|