This commit is contained in:
tisto 2012-01-14 07:26:01 +01:00
parent a3883d7e7b
commit 0558a9b739
5 changed files with 45 additions and 40 deletions

View File

@ -58,8 +58,8 @@ COMMENT_DESCRIPTION_MARKDOWN = _(
COMMENT_DESCRIPTION_INTELLIGENT_TEXT = _( COMMENT_DESCRIPTION_INTELLIGENT_TEXT = _(
u"comment_description_intelligent_text", u"comment_description_intelligent_text",
default=u"You can add a comment by filling out the form below. " + default=u"You can add a comment by filling out the form below. " +
"Plain text formatting. Web and email addresses are transformed " + "Plain text formatting. Web and email addresses are " +
"into clickable links.") "transformed into clickable links.")
COMMENT_DESCRIPTION_MODERATION_ENABLED = _( COMMENT_DESCRIPTION_MODERATION_ENABLED = _(
u"comment_description_moderation_enabled", u"comment_description_moderation_enabled",
@ -113,8 +113,8 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
member_email = member.getProperty('email') member_email = member.getProperty('email')
# Hide the user_notification checkbox if user notification is disabled # Hide the user_notification checkbox if user notification is disabled
# or the user is not logged in. Also check if the user has a valid email # or the user is not logged in. Also check if the user has a valid
# address # email address
if member_email == '' or \ if member_email == '' or \
not settings.user_notification_enabled or \ not settings.user_notification_enabled or \
mtool.isAnonymousUser(): mtool.isAnonymousUser():
@ -185,7 +185,8 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
comment.author_name = author_name comment.author_name = author_name
comment.author_email = author_email comment.author_email = author_email
comment.user_notification = user_notification comment.user_notification = user_notification
comment.creation_date = comment.modification_date = datetime.utcnow() comment.creation_date = datetime.utcnow()
comment.modification_date = datetime.utcnow()
elif not portal_membership.isAnonymousUser() and can_reply: elif not portal_membership.isAnonymousUser() and can_reply:
# Member # Member
member = portal_membership.getAuthenticatedMember() member = portal_membership.getAuthenticatedMember()
@ -204,7 +205,8 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
comment.author_name = fullname comment.author_name = fullname
comment.author_email = email comment.author_email = email
comment.user_notification = user_notification comment.user_notification = user_notification
comment.creation_date = comment.modification_date = datetime.utcnow() comment.creation_date = datetime.utcnow()
comment.modification_date = datetime.utcnow()
else: # pragma: no cover else: # pragma: no cover
raise Unauthorized("Anonymous user tries to post a comment, but " raise Unauthorized("Anonymous user tries to post a comment, but "
"anonymous commenting is disabled. Or user does not have the " "anonymous commenting is disabled. Or user does not have the "

View File

@ -60,7 +60,7 @@ class TestCommentForm(unittest.TestCase):
'portal_discussion', 'portal_discussion',
None) None)
self.discussionTool.overrideDiscussionFor(self.portal.doc1, False) self.discussionTool.overrideDiscussionFor(self.portal.doc1, False)
self.membershipTool = getToolByName(self.folder, 'portal_membership', None) self.membershipTool = getToolByName(self.folder, 'portal_membership')
self.memberdata = self.portal.portal_memberdata self.memberdata = self.portal.portal_memberdata
self.context = getattr(self.portal, 'doc1') self.context = getattr(self.portal, 'doc1')
@ -261,7 +261,8 @@ class TestCommentsViewlet(unittest.TestCase):
# Anonymous has no 'can review' permission # Anonymous has no 'can review' permission
self.assertFalse(self.viewlet.can_review()) self.assertFalse(self.viewlet.can_review())
# The reviewer role has the 'Review comments' permission # The reviewer role has the 'Review comments' permission
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], []) self.portal.acl_users._doAddUser(
'reviewer', 'secret', ['Reviewer'], [])
login(self.portal, 'reviewer') login(self.portal, 'reviewer')
self.assertTrue(self.viewlet.can_review()) self.assertTrue(self.viewlet.can_review())
@ -276,7 +277,8 @@ class TestCommentsViewlet(unittest.TestCase):
# Anonymous has no 'can review' permission # Anonymous has no 'can review' permission
self.assertFalse(self.viewlet.can_manage()) self.assertFalse(self.viewlet.can_manage())
# The reviewer role has the 'Review comments' permission # The reviewer role has the 'Review comments' permission
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], []) self.portal.acl_users._doAddUser(
'reviewer', 'secret', ['Reviewer'], [])
login(self.portal, 'reviewer') login(self.portal, 'reviewer')
self.assertTrue(self.viewlet.can_manage()) self.assertTrue(self.viewlet.can_manage())
@ -295,8 +297,8 @@ class TestCommentsViewlet(unittest.TestCase):
self.assertTrue(self.viewlet.comment_transform_message()) self.assertTrue(self.viewlet.comment_transform_message())
self.assertEqual( self.assertEqual(
self.viewlet.comment_transform_message(), self.viewlet.comment_transform_message(),
"You can add a comment by filling out the form below. Plain text " + "You can add a comment by filling out the form below. Plain " +
"formatting.") "text formatting.")
# Set text transform to intelligent text # Set text transform to intelligent text
registry = queryUtility(IRegistry) registry = queryUtility(IRegistry)
@ -358,7 +360,7 @@ class TestCommentsViewlet(unittest.TestCase):
('comment_review_workflow,')) ('comment_review_workflow,'))
# Check if workflow actions are available # Check if workflow actions are available
reply = self.viewlet.get_replies(workflow_actions=True).next() reply = self.viewlet.get_replies(workflow_actions=True).next()
self.assertTrue(reply.has_key('actions')) self.assertTrue('actions' in reply)
self.assertEqual(reply['actions'][0]['id'], self.assertEqual(reply['actions'][0]['id'],
'publish') 'publish')
self.assertEqual(reply['actions'][0]['url'], self.assertEqual(reply['actions'][0]['url'],

View File

@ -12,7 +12,8 @@ from Products.CMFCore.utils import getToolByName
from plone.app.testing import TEST_USER_ID, setRoles from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.discussion.interfaces import IDiscussionSettings from plone.app.discussion.interfaces import IDiscussionSettings
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING from plone.app.discussion.testing import \
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
class RegistryTest(unittest.TestCase): class RegistryTest(unittest.TestCase):
@ -166,5 +167,6 @@ class ConfigurationChangedSubscriberTest(unittest.TestCase):
# setting itself remains unchanged. # setting itself remains unchanged.
self.settings.moderation_enabled = True self.settings.moderation_enabled = True
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)

View File

@ -15,7 +15,8 @@ from Products.CMFCore.utils import getToolByName
from plone.app.testing import TEST_USER_ID, setRoles from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING from plone.app.discussion.testing import \
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
from plone.app.discussion import interfaces from plone.app.discussion import interfaces
from plone.app.discussion.interfaces import IConversation from plone.app.discussion.interfaces import IConversation
@ -179,7 +180,6 @@ class ConversationTest(unittest.TestCase):
# 1) allow_discussion attribute: Every content object in Plone # 1) allow_discussion attribute: Every content object in Plone
# has a allow_discussion attribute. By default it is set to None. # has a allow_discussion attribute. By default it is set to None.
# Create a conversation. # Create a conversation.
IConversation(self.portal.doc1) IConversation(self.portal.doc1)
@ -289,7 +289,6 @@ class ConversationTest(unittest.TestCase):
settings.globally_enabled = True settings.globally_enabled = True
self.assertEqual(conversation.enabled(), True) self.assertEqual(conversation.enabled(), True)
def test_allow_discussion_for_news_items(self): def test_allow_discussion_for_news_items(self):
self.typetool.constructContent('News Item', self.portal, 'newsitem') self.typetool.constructContent('News Item', self.portal, 'newsitem')
@ -710,8 +709,7 @@ class ConversationTest(unittest.TestCase):
self.assertFalse('Discussion Item' in BAD_TYPES) self.assertFalse('Discussion Item' in BAD_TYPES)
def test_no_comment(self): def test_no_comment(self):
conversation = IConversation(self.portal.doc1) IConversation(self.portal.doc1)
# Make sure no conversation has been created # Make sure no conversation has been created
self.assertTrue('plone.app.discussion:conversation' not in self.assertTrue('plone.app.discussion:conversation' not in
IAnnotations(self.portal.doc1)) IAnnotations(self.portal.doc1))
@ -850,5 +848,6 @@ class RepliesTest(unittest.TestCase):
self.assertEqual(len(replies_to_comment1_1), 1) self.assertEqual(len(replies_to_comment1_1), 1)
self.assertEqual(len(replies_to_comment2), 1) self.assertEqual(len(replies_to_comment2), 1)
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)