fix bug 834504. Replies have a wrong path index.

svn path=/plone.app.discussion/trunk/; revision=27657
This commit is contained in:
Timo Stollenwerk 2009-06-24 14:03:02 +00:00
parent e3e6d5548e
commit f088cb946e

View File

@ -142,6 +142,8 @@ class AddComment(BrowserView):
if self.request.has_key('form.button.AddComment'): if self.request.has_key('form.button.AddComment'):
context = aq_inner(self.context)
subject = self.request.get('subject') subject = self.request.get('subject')
text = self.request.get('body_text') text = self.request.get('body_text')
author_username = self.request.get('author_username') author_username = self.request.get('author_username')
@ -152,32 +154,32 @@ class AddComment(BrowserView):
IStatusMessage(self.request).addStatusMessage(\ IStatusMessage(self.request).addStatusMessage(\
_("Username field is empty."), _("Username field is empty."),
type="info") type="info")
return self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) return self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url())
if author_email == '': if author_email == '':
IStatusMessage(self.request).addStatusMessage(\ IStatusMessage(self.request).addStatusMessage(\
_("Email field is empty."), _("Email field is empty."),
type="info") type="info")
return self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) return self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url())
if subject == '': if subject == '':
IStatusMessage(self.request).addStatusMessage(\ IStatusMessage(self.request).addStatusMessage(\
_("Subject field is empty."), _("Subject field is empty."),
type="info") type="info")
return self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) return self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url())
if text == '': if text == '':
IStatusMessage(self.request).addStatusMessage(\ IStatusMessage(self.request).addStatusMessage(\
_("Comment field is empty."), _("Comment field is empty."),
type="info") type="info")
return self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) return self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url())
# The add-comment view is called on the conversation object # The add-comment view is called on the conversation object
conversation = self.context conversation = context
# Create the comment # Create the comment
comment = CommentFactory() comment = CommentFactory()
comment.title = subject comment.title = subject
comment.text = text comment.text = text
portal_membership = getToolByName(self.context, 'portal_membership') portal_membership = getToolByName(context, 'portal_membership')
if portal_membership.isAnonymousUser(): if portal_membership.isAnonymousUser():
comment.creator = author_username comment.creator = author_username
@ -200,8 +202,8 @@ class AddComment(BrowserView):
comment_id = conversation.addComment(comment) comment_id = conversation.addComment(comment)
# Redirect to comment (inside a content object page) # Redirect to comment (inside a content object page)
#self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url() + '#comment-' + str(comment_id)) #self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url() + '#comment-' + str(comment_id))
self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url() + '#' + str(comment_id)) self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url() + '#' + str(comment_id))
class ReplyToComment(BrowserView): class ReplyToComment(BrowserView):
"""Reply to a comment """Reply to a comment
@ -209,6 +211,8 @@ class ReplyToComment(BrowserView):
def __call__(self): def __call__(self):
context = aq_inner(self.context)
if self.request.has_key('form.button.AddComment'): if self.request.has_key('form.button.AddComment'):
reply_to_comment_id = self.request.get('form.reply_to_comment_id') reply_to_comment_id = self.request.get('form.reply_to_comment_id')
@ -223,25 +227,25 @@ class ReplyToComment(BrowserView):
IStatusMessage(self.request).addStatusMessage(\ IStatusMessage(self.request).addStatusMessage(\
_("Username field is empty."), _("Username field is empty."),
type="info") type="info")
return self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) return self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url())
if author_email == '': if author_email == '':
IStatusMessage(self.request).addStatusMessage(\ IStatusMessage(self.request).addStatusMessage(\
_("Email field is empty."), _("Email field is empty."),
type="info") type="info")
return self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) return self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url())
if subject == '': if subject == '':
IStatusMessage(self.request).addStatusMessage(\ IStatusMessage(self.request).addStatusMessage(\
_("Subject field is empty."), _("Subject field is empty."),
type="info") type="info")
return self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) return self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url())
if text == '': if text == '':
IStatusMessage(self.request).addStatusMessage(\ IStatusMessage(self.request).addStatusMessage(\
_("Comment field is empty."), _("Comment field is empty."),
type="info") type="info")
return self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url()) return self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url())
# The add-comment view is called on the conversation object # The add-comment view is called on the conversation object
conversation = self.context conversation = context
# Fetch the comment we want to reply to # Fetch the comment we want to reply to
comment_to_reply_to = conversation.get(reply_to_comment_id) comment_to_reply_to = conversation.get(reply_to_comment_id)
@ -253,7 +257,7 @@ class ReplyToComment(BrowserView):
comment.title = subject comment.title = subject
comment.text = text comment.text = text
portal_membership = getToolByName(self.context, 'portal_membership') portal_membership = getToolByName(context, 'portal_membership')
if portal_membership.isAnonymousUser(): if portal_membership.isAnonymousUser():
comment.creator = author_username comment.creator = author_username
@ -276,10 +280,10 @@ class ReplyToComment(BrowserView):
new_re_id = replies.addComment(comment) new_re_id = replies.addComment(comment)
# Redirect to comment (inside a content object page) # Redirect to comment (inside a content object page)
#self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url() + '#comment-' + str(reply_to_comment_id)) #self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url() + '#comment-' + str(reply_to_comment_id))
# Todo: Temporarily remove the "#comment-" to fix a bug # Todo: Temporarily remove the "#comment-" to fix a bug
# in CMFPlone/skins/plone_ecmascript/form_tabbing.js # in CMFPlone/skins/plone_ecmascript/form_tabbing.js
self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url() + '#' + str(reply_to_comment_id)) self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url() + '#' + str(reply_to_comment_id))
class DeleteComment(BrowserView): class DeleteComment(BrowserView):
"""Delete a comment from a conversation """Delete a comment from a conversation