Make handleComment method store comment attributes from form extenders. This allows us to extend the comment form with external add-ons.

svn path=/plone.app.discussion/trunk/; revision=50059
This commit is contained in:
Timo Stollenwerk 2011-05-26 21:37:37 +00:00
parent 1c2f1865a1
commit 1ea5f0cdb4
2 changed files with 18 additions and 11 deletions

View File

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

View File

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