source: WAeUP_SRP/trunk/skins/waeup_student/level_delete.py @ 11154

Last change on this file since 11154 was 3362, checked in by joachim, 17 years ago

fix for #112 okene, make create level more errortolerant

  • Property svn:keywords set to Id
File size: 2.4 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 3362 2008-03-20 16:20:15Z joachim $
11"""
12delete a level, fix students review if necessary
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19
20import logging
21logger = logging.getLogger('Skins.level_delete')
22member_id = str(context.portal_membership.getAuthenticatedMember())
23
24from Products.CMFCore.utils import getToolByName
25here = context
26
27ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type)
28meth_id = ti.queryMethodID('view', 'folder_contents')
29ret_url = here.absolute_url() + '/' + meth_id
30
31if 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'
60else:
61    message = 'portal_status_message=psm_select_at_least_one_document'
62
63if REQUEST is not None:
64    return REQUEST.RESPONSE.redirect(ret_url + '?' + message)
Note: See TracBrowser for help on using the repository browser.