fix delete and publish comment methods.

svn path=/plone.app.discussion/trunk/; revision=27415
This commit is contained in:
Timo Stollenwerk 2009-06-14 07:19:37 +00:00
parent 9e30b7b3c2
commit 9be49ee767
1 changed files with 10 additions and 12 deletions

View File

@ -208,16 +208,15 @@ class DeleteComment(BrowserView):
def __call__(self):
comment = aq_inner(self.context)
# Sanity check
comment_id = self.request.form['comment_id']
if comment_id != comment.getId():
raise ValueError
comment_id = self.context.id
conversation = self.context.__parent__
del conversation[comment_id]
self.context.plone_utils.addPortalMessage('Conversation %s deleted' % comment_id)
return self.context.REQUEST.RESPONSE.redirect(self.context.REQUEST.HTTP_REFERER)
class PublishComment(BrowserView):
"""Publish a comment
"""
@ -225,12 +224,11 @@ class PublishComment(BrowserView):
def __call__(self):
comment = aq_inner(self.context)
comment_id = self.context.id
# Sanity check
comment_id = self.request.form['comment_id']
if comment_id != comment.getId():
raise ValueError
action = self.request.form['action']
workflow_action = self.request.form['workflow_action']
portal_workflow = getToolByName(comment, 'portal_workflow')
portal_workflow.doActionFor(comment, action)
portal_workflow.doActionFor(comment, workflow_action)
self.context.plone_utils.addPortalMessage('Conversation %s workflow action %s' % (comment_id, workflow_action))
return self.context.REQUEST.RESPONSE.redirect(self.context.REQUEST.HTTP_REFERER)