Dynamically show the comment formatting message dependent on the text transform setting.
svn path=/plone.app.discussion/trunk/; revision=46035
This commit is contained in:
parent
ea2ff81b43
commit
0c94707743
@ -4,6 +4,10 @@ Changelog
|
||||
1.0RC1 (unreleased)
|
||||
-------------------
|
||||
|
||||
- Dynamically show the comment formatting message dependent on the text
|
||||
transform setting.
|
||||
[timo]
|
||||
|
||||
- Description for text transform added to the discussion control panel.
|
||||
[timo]
|
||||
|
||||
|
@ -145,7 +145,7 @@
|
||||
<fieldset>
|
||||
|
||||
<legend i18n:translate="label_add_comment">Add comment</legend>
|
||||
<p i18n:translate="description_add_comment">
|
||||
<p tal:content="view/comment_transform_message">
|
||||
You can add a comment by filling out the form below. Plain text
|
||||
formatting.
|
||||
</p>
|
||||
|
@ -9,6 +9,9 @@ from DateTime import DateTime
|
||||
|
||||
from urllib import quote as url_quote
|
||||
|
||||
from zope.i18n import translate
|
||||
from zope.i18nmessageid import Message
|
||||
|
||||
from zope.component import createObject, queryUtility
|
||||
|
||||
from zope.interface import alsoProvides
|
||||
@ -45,6 +48,17 @@ try:
|
||||
except ImportError: # pragma: no cover
|
||||
HAS_WRAPPED_FORM = False
|
||||
|
||||
COMMENT_DESCRIPTION_PLAIN_TEXT = _(
|
||||
u"comment_description_plain_text",
|
||||
default=u"You can add a comment by filling out the form below. " +
|
||||
"Plain text formatting.")
|
||||
|
||||
COMMENT_DESCRIPTION_INTELLIGENT_TEXT = _(
|
||||
u"comment_description_intelligent_text",
|
||||
default=u"You can add a comment by filling out the form below. " +
|
||||
"Plain text formatting. Web and email addresses are transformed " +
|
||||
"into clickable links.")
|
||||
|
||||
|
||||
class CommentForm(extensible.ExtensibleForm, form.Form):
|
||||
|
||||
@ -274,6 +288,20 @@ class CommentsViewlet(ViewletBase):
|
||||
conversation = IConversation(context)
|
||||
return conversation.enabled()
|
||||
|
||||
def comment_transform_message(self):
|
||||
"""Returns the description that shows up above the comment text,
|
||||
dependent on the text_transform setting of the discussion control
|
||||
panel.
|
||||
"""
|
||||
registry = queryUtility(IRegistry)
|
||||
settings = registry.forInterface(IDiscussionSettings, check=False)
|
||||
|
||||
if settings.text_transform == "text/x-web-intelligent":
|
||||
message = translate(Message(COMMENT_DESCRIPTION_INTELLIGENT_TEXT))
|
||||
else:
|
||||
message = translate(Message(COMMENT_DESCRIPTION_PLAIN_TEXT))
|
||||
return message
|
||||
|
||||
def has_replies(self, workflow_actions=False):
|
||||
"""Returns true if there are replies.
|
||||
"""
|
||||
|
@ -284,6 +284,27 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
portal_discussion.overrideDiscussionFor(self.portal.doc1, True)
|
||||
# Test if discussion has been enabled
|
||||
self.failUnless(self.viewlet.is_discussion_allowed())
|
||||
|
||||
def test_comment_transform_message(self):
|
||||
# Default transform is plain/text
|
||||
self.failUnless(self.viewlet.comment_transform_message())
|
||||
self.assertEquals(
|
||||
self.viewlet.comment_transform_message(),
|
||||
"You can add a comment by filling out the form below. Plain text " +
|
||||
"formatting.")
|
||||
|
||||
# Set text transform to intelligent text
|
||||
registry = queryUtility(IRegistry)
|
||||
settings = registry.forInterface(IDiscussionSettings, check=False)
|
||||
settings.text_transform = "text/x-web-intelligent"
|
||||
|
||||
# Make sure the comment description is changes accordingly
|
||||
self.assertEquals(
|
||||
self.viewlet.comment_transform_message(),
|
||||
"You can add a comment by filling out the form below. " +
|
||||
"Plain text formatting. Web and email addresses are transformed " +
|
||||
"into clickable links.")
|
||||
|
||||
|
||||
def test_has_replies(self):
|
||||
self.assertEquals(self.viewlet.has_replies(), False)
|
||||
|
Loading…
Reference in New Issue
Block a user