source: products/qPloneComments/trunk/skins/qplonecomments/prefs_recent_comments_delete.cpy @ 1

Last change on this file since 1 was 1, checked in by myroslav, 14 years ago

Building directory structure

File size: 1.1 KB
Line 
1## Script (Python) "prefs_recent_comments_delete"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10from Products.CMFCore.utils import getToolByName
11from Products.qPloneComments.utils import manage_mails
12from Products.qPloneComments.utils import setStatusMsg
13
14portal_discussion = getToolByName(context, "portal_discussion")
15portal_catalog = getToolByName(context, "portal_catalog")
16
17request = context.REQUEST
18comment_ids = request.get('ids', [])
19
20for comment_id in comment_ids:
21    comment = portal_catalog(id=comment_id,portal_type='Discussion Item')[0].getObject()
22
23    parent = comment.inReplyTo()
24    if parent is not None:
25        talkback = portal_discussion.getDiscussionFor(parent)
26    else:
27        talkback = parent = comment.aq_parent
28
29    comment = portal_catalog(id=comment_id,portal_type='Discussion Item')[0].getObject()
30    talkback.deleteReply(comment_id)
31    manage_mails(comment, context, 'deleting')
32
33msg = comment_ids and u'Comment(s) deleted.' or u'Please select items to be processed.'
34setStatusMsg(state, context, msg)
35
36return state
Note: See TracBrowser for help on using the repository browser.