Back to index

plone3  3.1.7
deleteDiscussion.py
Go to the documentation of this file.
00001 ## Script (Python) "deleteDiscussion"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=obj=None
00008 ##title=Delete discussion item
00009 ##
00010 
00011 from Products.CMFPlone import PloneMessageFactory as _
00012 
00013 if obj is None:
00014     obj=context
00015 
00016 parent = obj.inReplyTo()
00017 if parent is not None:
00018     talkback = context.portal_discussion.getDiscussionFor(parent)
00019 else:
00020     talkback = parent = obj.aq_parent
00021 
00022 # remove the discussion item
00023 talkback.deleteReply( obj.getId() )
00024 
00025 # redirect to the object that is being discussed
00026 redirect_target = context.plone_utils.getDiscussionThread(talkback)[0]
00027 context.plone_utils.addPortalMessage(_(u'Reply deleted.'))
00028 
00029 context.REQUEST['RESPONSE'].redirect( redirect_target.absolute_url() + '/view')