source: products/qPloneComments/branches/plone-2.1/skins/qplonecomments/discussion_publish_comment.py @ 205

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

Building directory structure

File size: 1.2 KB
Line 
1## Script (Python) "discussion_publish_comment"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=obj=None
8##title=
9##
10from Products.CMFPlone import transaction_note
11from Products.CMFCore.utils import getToolByName
12from Products.qPloneComments.utils import publishDiscussion, send_email
13
14if obj is None:
15    obj=context
16
17parent = obj.inReplyTo()
18if parent is not None:
19    dtool = getToolByName(context, 'portal_discussion')
20    talkback = dtool.getDiscussionFor(parent)
21else:
22    talkback = parent = obj.aq_parent
23
24reply = talkback.getReply( obj.getId() )
25publishDiscussion(reply)
26
27send_notification_message = send_email(reply, container, state="published")
28
29portal_status_message='Comment+successfully+published'
30
31putils = getToolByName(context, 'plone_utils')
32redirect_target = putils.getDiscussionThread(talkback)[0]
33view = redirect_target.getTypeInfo().getActionById('view')
34anchor = reply.getId()
35
36transaction_note('Published discussion item')
37target = '%s/%s?portal_status_message=%s#%s' % (redirect_target.absolute_url(), view, portal_status_message, anchor)
38
39return context.REQUEST.RESPONSE.redirect(target)
Note: See TracBrowser for help on using the repository browser.