source: WAeUP_SRP/base/skins/waeup_student/level_delete.py @ 2504

Last change on this file since 2504 was 2448, checked in by Henrik Bettermann, 17 years ago

new course registration module

  • Property svn:keywords set to Id
File size: 2.2 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 2448 2007-10-27 12:03:25Z henrik $
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
22ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type)
23meth_id = ti.queryMethodID('view', 'folder_contents')
24ret_url = here.absolute_url() + '/' + meth_id
25
26if 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'
54else:
55    message = 'portal_status_message=psm_select_at_least_one_document'
56
57if REQUEST is not None:
58    return REQUEST.RESPONSE.redirect(ret_url + '?' + message)
Note: See TracBrowser for help on using the repository browser.