Last change
on this file since 864 was
331,
checked in by piv, 18 years ago
|
debug mode set to false
|
-
Property svn:eol-style set to
native
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1] | 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 | ## |
---|
| 10 | from Products.CMFPlone.utils import transaction_note |
---|
| 11 | from Products.CMFCore.utils import getToolByName |
---|
| 12 | from Products.qPloneComments.utils import publishDiscussion |
---|
| 13 | from Products.qPloneComments.utils import manage_mails |
---|
| 14 | from Products.CMFPlone import MessageFactory |
---|
[331] | 15 | _ = MessageFactory('plonecomments') |
---|
[1] | 16 | |
---|
| 17 | if obj is None: |
---|
[92] | 18 | obj = context |
---|
[1] | 19 | |
---|
| 20 | parent = obj.inReplyTo() |
---|
| 21 | if parent is not None: |
---|
| 22 | dtool = getToolByName(context, 'portal_discussion') |
---|
| 23 | talkback = dtool.getDiscussionFor(parent) |
---|
| 24 | else: |
---|
| 25 | talkback = parent = obj.aq_parent |
---|
| 26 | |
---|
[92] | 27 | reply = talkback.getReply(obj.getId()) |
---|
[1] | 28 | publishDiscussion(reply) |
---|
| 29 | manage_mails(reply, context, action='publishing') |
---|
| 30 | |
---|
| 31 | putils = getToolByName(context, 'plone_utils') |
---|
| 32 | redirect_target = putils.getDiscussionThread(talkback)[0] |
---|
| 33 | view = redirect_target.getTypeInfo().getActionInfo('object/view')['url'] |
---|
| 34 | anchor = reply.getId() |
---|
| 35 | |
---|
| 36 | transaction_note('Published discussion item') |
---|
| 37 | |
---|
[331] | 38 | context.plone_utils.addPortalMessage(_(u'Comment published.')) |
---|
[1] | 39 | target = '%s/%s#%s' % (redirect_target.absolute_url(), view, anchor) |
---|
| 40 | |
---|
[92] | 41 | return context.REQUEST.RESPONSE.redirect(target) |
---|
Note: See
TracBrowser
for help on using the repository browser.