From bda70af8283c8f0c4f390f8efe10084aff24b547 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Tue, 26 May 2009 19:58:33 +0000 Subject: [PATCH] reply-to-comment view and jquery forms added. svn path=/plone.app.discussion/trunk/; revision=27127 --- plone/app/discussion/browser/comments.pt | 7 +++++ plone/app/discussion/browser/comments.py | 34 +++++++++++++++++++-- plone/app/discussion/browser/configure.zcml | 23 ++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/plone/app/discussion/browser/comments.pt b/plone/app/discussion/browser/comments.pt index c1551ad..5a508ed 100644 --- a/plone/app/discussion/browser/comments.pt +++ b/plone/app/discussion/browser/comments.pt @@ -3,6 +3,7 @@ i18n:domain="plone">
+
+ + + +
diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index eff5eb3..09cf544 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -8,8 +8,7 @@ from Acquisition import aq_inner, aq_parent from Products.Five.browser import BrowserView from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile -from plone.app.discussion.interfaces import IComment - +from plone.app.discussion.interfaces import IComment, IReplies from plone.app.discussion.conversation import conversationAdapterFactory from plone.app.discussion.comment import CommentFactory @@ -66,5 +65,36 @@ class AddComment(BrowserView): # Add comment to the conversation conversation.addComment(comment) + # Redirect to the document object page + self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) + +class ReplyToComment(BrowserView): + """Reply to a comment + """ + + def __call__(self): + + if self.request.has_key('form.button.AddComment'): + + reply_to_comment_id = self.request.get('form.reply_to_comment_id') + subject = self.request.get('subject') + text = self.request.get('body_text') + + # The add-comment view is called on the conversation object + conversation = self.context + + # Fetch the comment we want to reply to + comment_to_reply_to = conversation.get(reply_to_comment_id) + + replies = IReplies(comment_to_reply_to) + + # Create the comment + comment = CommentFactory() + comment.title = subject + comment.text = text + + # Add the reply to the comment + new_re_id = replies.addComment(comment) + # TODO: Redirect to the document object page self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) diff --git a/plone/app/discussion/browser/configure.zcml b/plone/app/discussion/browser/configure.zcml index 62c46be..dee97f5 100644 --- a/plone/app/discussion/browser/configure.zcml +++ b/plone/app/discussion/browser/configure.zcml @@ -27,4 +27,27 @@ permission="zope2.View" /> + + + + + + + + +