diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index 1eddf0a..6be93a2 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -168,6 +168,10 @@ class CommentForm(extensible.ExtensibleForm, form.Form): # Create comment comment = createObject('plone.Comment') + + # Set comment mime type to current setting in the discussion registry + comment.mime_type = settings.text_transform + # Set comment attributes (including extended comment form attributes) for attribute in self.fields.keys(): setattr(comment, attribute, data[attribute]) diff --git a/plone/app/discussion/comment.py b/plone/app/discussion/comment.py index 78baf8b..7b4c12c 100644 --- a/plone/app/discussion/comment.py +++ b/plone/app/discussion/comment.py @@ -90,7 +90,7 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable, title = u"" - mime_type = None + mime_type = "text/plain" text = u"" creator = None @@ -205,6 +205,10 @@ def notify_content_object(obj, event): """Tell the content object when a comment is added """ content_obj = aq_parent(aq_parent(obj)) + # set the modified date and reindex the item accordingly + # so that 304s work correctly. This means that adding a comment + # effectively counts as modifying the content type. + content_obj.setModificationDate() content_obj.reindexObject(idxs=('total_comments', 'last_comment_date', 'commentators', diff --git a/plone/app/discussion/tests/test_comment.py b/plone/app/discussion/tests/test_comment.py index 307c646..3afe87e 100644 --- a/plone/app/discussion/tests/test_comment.py +++ b/plone/app/discussion/tests/test_comment.py @@ -127,6 +127,10 @@ class CommentTest(unittest.TestCase): comment1 = createObject('plone.Comment') self.assertEqual(comment1.Type(), 'Comment') + def test_mime_type(self): + comment1 = createObject('plone.Comment') + self.assertEqual(comment1.mime_type, 'text/plain') + def test_getText(self): comment1 = createObject('plone.Comment') comment1.text = """First paragraph