diff --git a/CHANGES.txt b/CHANGES.txt index 42b0ec2..1797c24 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,10 @@ Changelog 2.0.4 (Unreleased) ------------------ +- Make handleComment method store comment attributes from form extenders. This + allows us to extend the comment form with external add-ons. + [timo] + 2.0.3 (2011-06-19) ------------------ diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index 11d6749..fad9c6a 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -151,7 +151,14 @@ class CommentForm(extensible.ExtensibleForm, form.Form): ICaptcha['captcha'], None) captcha.validate(data['captcha']) - + + # Create a comment + comment = createObject('plone.Comment') + comment.text = text + + for attribute in self.fields.keys(): + setattr(comment, attribute, data[attribute]) + # Fetch data from request if 'text' in data: text = data['text'] @@ -163,30 +170,26 @@ class CommentForm(extensible.ExtensibleForm, form.Form): author_email = data['author_email'] if 'user_notification' in data: user_notification = data['user_notification'] - + # Check if conversation is enabled on this content object if not self.__parent__.restrictedTraverse( '@@conversation_view').enabled(): raise Unauthorized("Discussion is not enabled for this content " "object.") - + # The add-comment view is called on the conversation object conversation = IConversation(self.__parent__) - + if data['in_reply_to']: # Fetch the comment we want to reply to conversation_to_reply_to = conversation.get(data['in_reply_to']) replies = IReplies(conversation_to_reply_to) - - # Create the comment - comment = createObject('plone.Comment') - comment.text = text - + portal_membership = getToolByName(self.context, 'portal_membership') - + can_reply = getSecurityManager().checkPermission('Reply to item', context) - + if portal_membership.isAnonymousUser() and \ settings.anonymous_comments: # Anonymous Users