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 2448 2007-10-27 12:03:25Z 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 | for level_id in ids:
|
---|
50 | context.course_results.deleteResultsHere(level_id,student_id)
|
---|
51 | here.manage_delObjects(ids)
|
---|
52 |
|
---|
53 | message = 'portal_status_message=psm_item(s)_deleted'
|
---|
54 | else:
|
---|
55 | message = 'portal_status_message=psm_select_at_least_one_document'
|
---|
56 |
|
---|
57 | if REQUEST is not None:
|
---|
58 | return REQUEST.RESPONSE.redirect(ret_url + '?' + message)
|
---|