source: products/qPloneComments/branches/plone3_extend/skins/qplonecomments/discussion_edit.cpy @ 858

Last change on this file since 858 was 858, checked in by crchemist, 17 years ago

Place captchas before register button.

File size: 1.5 KB
RevLine 
[858]1## Script (Python) "discussion_edit"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=subject,body_text
8##title=Delete discussion item
9##
10
11from Products.PythonScripts.standard import url_quote_plus
12from Products.CMFCore.utils import getToolByName
13from Products.CMFPlone import PloneMessageFactory as _
14dtool = getToolByName(context, 'portal_discussion')
15req = context.REQUEST
16
17tb = dtool.getDiscussionFor(context)
18id = context.getId()
19reply = tb.getReply(id)
20
21modif_date = reply.modification_date
22
23# Set Title
24reply.setTitle(subject)
25
26# Update text
27reply.edit(text_format=reply.Format(), text=body_text)
28
29# TODO THIS NEEDS TO GO AWAY!
30if hasattr(dtool.aq_explicit, 'cookReply'):
31    dtool.cookReply(reply, text_format='plain')
32
33# Set modification date to old value
34reply.setModificationDate(modification_date=modif_date)
35
36parent = tb.aq_parent
37
38# return to the discussable object.
39redirect_target = context.plone_utils.getDiscussionThread(tb)[0]
40view = redirect_target.getTypeInfo().getActionInfo('object/view',
41                                                   redirect_target)['url']
42anchor = reply.getId()
43
44from Products.CMFPlone.utils import transaction_note
45transaction_note('Added comment to %s at %s' % (parent.title_or_id(),
46                                                reply.absolute_url()))
47
48context.plone_utils.addPortalMessage(_(u'Comment updated.'))
49target = '%s#%s' % (view, anchor)
50return req.RESPONSE.redirect(target)
Note: See TracBrowser for help on using the repository browser.