From a5c8fe33ede50f8240990626bafea27866a214e3 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Tue, 4 Aug 2009 12:55:46 +0000 Subject: [PATCH] redirect after adding a comment. remove unnecessary Comment class. svn path=/plone.app.discussion/trunk/; revision=28348 --- plone/app/discussion/browser/comments.py | 34 +++++------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index c5c9289..819f890 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -27,7 +27,7 @@ from plone.registry.interfaces import IRegistry from plone.app.layout.viewlets.common import ViewletBase -from plone.app.discussion.comment import CommentFactory +from plone.app.discussion.comment import Comment, CommentFactory from plone.app.discussion.interfaces import IConversation, IComment, IReplies, IDiscussionSettings ### NEW ### @@ -58,34 +58,16 @@ from Products.Five.browser import BrowserView from zope.schema.fieldproperty import FieldProperty class View(BrowserView): - """Comment View + """Comment View. + + Redirect from /path/to/object/++conversation++default/123456789 + to /path/to/object#comment-123456789. """ def __call__(self): - # Redirect from /path/to/object/++conversation++default/123456789 - # to /path/to/object#comment-123456789 comment_id = aq_parent(self).id - #self.request.response.redirect(aq_parent(aq_parent(aq_parent(self))).absolute_url() + '#comment-' + comment_id) self.request.response.redirect(aq_parent(aq_parent(aq_parent(self))).absolute_url() + '#' + comment_id) - -class Comment(object): - implements(IComment, IAttributeAnnotatable) - portal_type = u"" - __parent__ = None - __name__ = None - comment_id = u"" - in_reply_to = u"" - title = u"" - mime_type = u"" - text = u"" - creator = u"" - creation_date = u"" - modification_date = u"" - author_username = u"" - author_name = u"" - author_email = u"" - class CommentForm(extensible.ExtensibleForm, form.Form): ignoreContext = True # don't use context to get widget data @@ -107,9 +89,6 @@ class CommentForm(extensible.ExtensibleForm, form.Form): @button.buttonAndHandler(u'Post comment') def handleApply(self, action): data, errors = self.extractData() - if errors: - self.status = form.EditForm.formErrorsMessage - return if data.has_key('title'): subject = data['title'] @@ -151,8 +130,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form): comment_id = conversation.addComment(comment) # Redirect to comment (inside a content object page) - #self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url() + '#comment-' + str(comment_id)) - #self.request.response.redirect(aq_parent(aq_inner(context)).absolute_url() + '#' + str(comment_id)) + self.request.response.redirect(aq_parent(aq_inner(self.context)).absolute_url() + '#' + str(comment_id)) class ViewletFormWrapper(ViewletBase, layout.FormWrapper):