source: products/quintagroup.plonecomments/trunk/quintagroup/plonecomments/skins/quintagroup_plonecomments/discussion_publish_comment.py @ 1059

Last change on this file since 1059 was 1059, checked in by liebster, 15 years ago

Fixed links in the email messages. Change tests for Plone 3.1.7

File size: 1.4 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.utils import transaction_note
11from Products.CMFCore.utils import getToolByName
12from quintagroup.plonecomments.utils import publishDiscussion, manage_mails
13from Products.CMFPlone import MessageFactory
14_ = MessageFactory('quintagroup.plonecomments')
15
16if obj is None:
17    obj = context
18
19parent = obj.inReplyTo()
20if parent is not None:
21    dtool = getToolByName(context, 'portal_discussion')
22    talkback = dtool.getDiscussionFor(parent)
23else:
24    talkback = parent = obj.aq_parent
25
26reply = talkback.getReply(obj.getId())
27publishDiscussion(reply)
28manage_mails(reply, context, action='publishing')
29
30putils = getToolByName(context, 'plone_utils')
31redirect_target = putils.getDiscussionThread(talkback)[0]
32view = redirect_target.getTypeInfo().getActionInfo('object/view')['url']
33rt = redirect_target.absolute_url()
34
35if rt and rt[-1] == '/':
36    rt = rt[:-1]
37
38if view and view[0] == '/':
39    view = view[1:]
40
41if view and view[-1] == '/':
42    view = view[:-1]
43
44anchor = reply.getId()
45
46transaction_note('Published discussion item')
47
48context.plone_utils.addPortalMessage(_(u'Comment published.'))
49target = '%s/%s#%s' % (rt, view, anchor)
50
51return context.REQUEST.RESPONSE.redirect(target)
Note: See TracBrowser for help on using the repository browser.