reply-to-comment view and jquery forms added.

svn path=/plone.app.discussion/trunk/; revision=27127
This commit is contained in:
Timo Stollenwerk 2009-05-26 19:58:33 +00:00
parent 2b0133aa64
commit bda70af828
3 changed files with 62 additions and 2 deletions

View File

@ -3,6 +3,7 @@
i18n:domain="plone">
<div class="discussion">
<tal:getreplies repeat="reply_dict replies">
<div class="comment"
@ -31,6 +32,12 @@
This is the body text of the comment.
</div>
<a href="#" class="reply-to-comment-button" title="reply to this comment"
tal:attributes="onclick string:createReplyToCommentForm(${reply/id});
id string:reply-to-comment-${reply/id}-button">
<img src="++resource++plone.app.discussion.images/reply.gif" />
</a>
</div>
</tal:getreplies>

View File

@ -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())

View File

@ -27,4 +27,27 @@
permission="zope2.View"
/>
<!-- reply-to-comment view -->
<browser:view
name="reply-to-comment"
for="plone.app.discussion.interfaces.IConversation"
layer="..interfaces.IDiscussionLayer"
class=".comments.ReplyToComment"
permission="zope2.View"
/>
<!-- Resource directory for javascripts -->
<browser:resourceDirectory
name="plone.app.discussion.javascripts"
directory="javascripts"
layer="..interfaces.IDiscussionLayer"
/>
<!-- Resource directory for images -->
<browser:resourceDirectory
name="plone.app.discussion.images"
directory="images"
layer="..interfaces.IDiscussionLayer"
/>
</configure>