source: WAeUP_SRP/trunk_not_used/skins/waeup_student/level_delete.py @ 2940

Last change on this file since 2940 was 2138, checked in by joachim, 17 years ago

new script level_delete used in study_course_view

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
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"""
12delete a level, fix students review if necessary
13"""
14
15import logging
16logger = logging.getLogger('Skins.folder_delete')
17member_id = str(context.portal_membership.getAuthenticatedMember())
18
19from Products.CMFCore.utils import getToolByName
20here = context
21
22#if context.portal_type == "University":
23#    here = context.academics
24
25ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type)
26meth_id = ti.queryMethodID('view', 'folder_contents')
27ret_url = here.absolute_url() + '/' + meth_id
28
29if 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'
53else:
54    message = 'portal_status_message=psm_select_at_least_one_document'
55
56if REQUEST is not None:
57    return REQUEST.RESPONSE.redirect(ret_url + '?' + message)
Note: See TracBrowser for help on using the repository browser.