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 3362 2008-03-20 16:20:15Z joachim $
|
---|
11 | """
|
---|
12 | delete a level, fix students review if necessary
|
---|
13 | """
|
---|
14 | try:
|
---|
15 | from Products.zdb import set_trace
|
---|
16 | except:
|
---|
17 | def set_trace():
|
---|
18 | pass
|
---|
19 |
|
---|
20 | import logging
|
---|
21 | logger = logging.getLogger('Skins.level_delete')
|
---|
22 | member_id = str(context.portal_membership.getAuthenticatedMember())
|
---|
23 |
|
---|
24 | from Products.CMFCore.utils import getToolByName
|
---|
25 | here = context
|
---|
26 |
|
---|
27 | ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type)
|
---|
28 | meth_id = ti.queryMethodID('view', 'folder_contents')
|
---|
29 | ret_url = here.absolute_url() + '/' + meth_id
|
---|
30 |
|
---|
31 | if ids:
|
---|
32 | current_level = getattr(context.getContent(),'current_level','')
|
---|
33 | current_level_deleted = (current_level in ids)
|
---|
34 | student_id = context.getStudentId()
|
---|
35 | student_state = context.getStudentReviewState(student_id=student_id)
|
---|
36 | if current_level_deleted and student_state != "school_fee_paid":
|
---|
37 | students_folder = context.portal_url.getPortalObject().campus.students
|
---|
38 | student = getattr(students_folder,student_id)
|
---|
39 | from Products.CMFCore.WorkflowCore import WorkflowException
|
---|
40 | wftool = context.portal_workflow
|
---|
41 | try:
|
---|
42 | wftool.doActionFor(student,'reject_courses')
|
---|
43 | except WorkflowException,E:
|
---|
44 | pass
|
---|
45 | #logger.info('%s WorkflowException %s for %s' % (member_id,E,student_id))
|
---|
46 | #return context.REQUEST.RESPONSE.redirect("%s" % context.absolute_url())
|
---|
47 | # for id in ids:
|
---|
48 | # XXX has to be called from here since the workflow doesn't handle the
|
---|
49 | # deletion yet
|
---|
50 | # ob = getattr(here, id)
|
---|
51 | # from Products.CPSCore.EventServiceTool import getPublicEventService
|
---|
52 | # evtool = getPublicEventService(here)
|
---|
53 | # evtool.notifyEvent('workflow_delete', ob, {})
|
---|
54 | context.waeup_tool.updateRoleMappingsFor('waeup_student_subobject_wf',context)
|
---|
55 | for level_id in ids:
|
---|
56 | context.course_results.deleteResultsHere(level_id,student_id)
|
---|
57 | logger.info("%s deleted level(s) %s of %s" % (member_id,','.join(ids),student_id))
|
---|
58 | here.manage_delObjects(ids)
|
---|
59 | message = 'portal_status_message=psm_item(s)_deleted'
|
---|
60 | else:
|
---|
61 | message = 'portal_status_message=psm_select_at_least_one_document'
|
---|
62 |
|
---|
63 | if REQUEST is not None:
|
---|
64 | return REQUEST.RESPONSE.redirect(ret_url + '?' + message)
|
---|