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:
parent
1c2f1865a1
commit
1ea5f0cdb4
@ -4,6 +4,10 @@ Changelog
|
|||||||
2.0.4 (Unreleased)
|
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)
|
2.0.3 (2011-06-19)
|
||||||
------------------
|
------------------
|
||||||
|
@ -151,7 +151,14 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
|||||||
ICaptcha['captcha'],
|
ICaptcha['captcha'],
|
||||||
None)
|
None)
|
||||||
captcha.validate(data['captcha'])
|
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
|
# Fetch data from request
|
||||||
if 'text' in data:
|
if 'text' in data:
|
||||||
text = data['text']
|
text = data['text']
|
||||||
@ -163,30 +170,26 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
|||||||
author_email = data['author_email']
|
author_email = data['author_email']
|
||||||
if 'user_notification' in data:
|
if 'user_notification' in data:
|
||||||
user_notification = data['user_notification']
|
user_notification = data['user_notification']
|
||||||
|
|
||||||
# Check if conversation is enabled on this content object
|
# Check if conversation is enabled on this content object
|
||||||
if not self.__parent__.restrictedTraverse(
|
if not self.__parent__.restrictedTraverse(
|
||||||
'@@conversation_view').enabled():
|
'@@conversation_view').enabled():
|
||||||
raise Unauthorized("Discussion is not enabled for this content "
|
raise Unauthorized("Discussion is not enabled for this content "
|
||||||
"object.")
|
"object.")
|
||||||
|
|
||||||
# The add-comment view is called on the conversation object
|
# The add-comment view is called on the conversation object
|
||||||
conversation = IConversation(self.__parent__)
|
conversation = IConversation(self.__parent__)
|
||||||
|
|
||||||
if data['in_reply_to']:
|
if data['in_reply_to']:
|
||||||
# Fetch the comment we want to reply to
|
# Fetch the comment we want to reply to
|
||||||
conversation_to_reply_to = conversation.get(data['in_reply_to'])
|
conversation_to_reply_to = conversation.get(data['in_reply_to'])
|
||||||
replies = IReplies(conversation_to_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')
|
portal_membership = getToolByName(self.context, 'portal_membership')
|
||||||
|
|
||||||
can_reply = getSecurityManager().checkPermission('Reply to item',
|
can_reply = getSecurityManager().checkPermission('Reply to item',
|
||||||
context)
|
context)
|
||||||
|
|
||||||
if portal_membership.isAnonymousUser() and \
|
if portal_membership.isAnonymousUser() and \
|
||||||
settings.anonymous_comments:
|
settings.anonymous_comments:
|
||||||
# Anonymous Users
|
# Anonymous Users
|
||||||
|
Loading…
Reference in New Issue
Block a user