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 2817 2007-11-28 15:01:47Z 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:
|
---|
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 | context.waeup_tool.updateRoleMappingsFor('waeup_student_subobject_wf',context)
|
---|
50 | for level_id in ids:
|
---|
51 | context.course_results.deleteResultsHere(level_id,student_id)
|
---|
52 | here.manage_delObjects(ids)
|
---|
53 |
|
---|
54 | message = 'portal_status_message=psm_item(s)_deleted'
|
---|
55 | else:
|
---|
56 | message = 'portal_status_message=psm_select_at_least_one_document'
|
---|
57 |
|
---|
58 | if REQUEST is not None:
|
---|
59 | return REQUEST.RESPONSE.redirect(ret_url + '?' + message) |
---|