Pep8
This commit is contained in:
parent
2dc5393ff2
commit
aa36c0bc9b
@ -25,6 +25,7 @@ MAX_DESCRIPTION = 25
|
|||||||
|
|
||||||
# Conversation Indexers
|
# Conversation Indexers
|
||||||
|
|
||||||
|
|
||||||
@indexer(IContentish, IZCatalog)
|
@indexer(IContentish, IZCatalog)
|
||||||
def total_comments(object):
|
def total_comments(object):
|
||||||
# Total number of comments on a conversation
|
# Total number of comments on a conversation
|
||||||
@ -33,11 +34,12 @@ def total_comments(object):
|
|||||||
try:
|
try:
|
||||||
conversation = IConversation(object)
|
conversation = IConversation(object)
|
||||||
return conversation.total_comments
|
return conversation.total_comments
|
||||||
except TypeError: # pragma: no cover
|
except TypeError: # pragma: no cover
|
||||||
# The item is contentish but nobody
|
# The item is contentish but nobody
|
||||||
# implemented an adapter for it
|
# implemented an adapter for it
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@indexer(IContentish, IZCatalog)
|
@indexer(IContentish, IZCatalog)
|
||||||
def last_comment_date(object):
|
def last_comment_date(object):
|
||||||
# Date of the latest comment on a conversation
|
# Date of the latest comment on a conversation
|
||||||
@ -46,11 +48,12 @@ def last_comment_date(object):
|
|||||||
try:
|
try:
|
||||||
conversation = IConversation(object)
|
conversation = IConversation(object)
|
||||||
return conversation.last_comment_date
|
return conversation.last_comment_date
|
||||||
except TypeError: # pragma: no cover
|
except TypeError: # pragma: no cover
|
||||||
# The item is contentish but nobody
|
# The item is contentish but nobody
|
||||||
# implemented an adapter for it
|
# implemented an adapter for it
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@indexer(IContentish, IZCatalog)
|
@indexer(IContentish, IZCatalog)
|
||||||
def commentators(object):
|
def commentators(object):
|
||||||
# List of commentators on a conversation
|
# List of commentators on a conversation
|
||||||
@ -59,39 +62,46 @@ def commentators(object):
|
|||||||
try:
|
try:
|
||||||
conversation = IConversation(object)
|
conversation = IConversation(object)
|
||||||
return tuple(conversation.commentators.keys())
|
return tuple(conversation.commentators.keys())
|
||||||
except TypeError: # pragma: no cover
|
except TypeError: # pragma: no cover
|
||||||
# The item is contentish but nobody
|
# The item is contentish but nobody
|
||||||
# implemented an adapter for it
|
# implemented an adapter for it
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Comment Indexers
|
# Comment Indexers
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def title(object):
|
def title(object):
|
||||||
return object.Title()
|
return object.Title()
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def creator(object):
|
def creator(object):
|
||||||
return object.creator and safe_unicode(object.creator).encode('utf-8')
|
return object.creator and safe_unicode(object.creator).encode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def description(object):
|
def description(object):
|
||||||
# Return the first 25 words of the comment text and append ' [...]'
|
# Return the first 25 words of the comment text and append ' [...]'
|
||||||
text = join(object.getText(targetMimetype='text/plain').split()[:MAX_DESCRIPTION])
|
text = join(object.getText(
|
||||||
|
targetMimetype='text/plain').split()[:MAX_DESCRIPTION])
|
||||||
if len(object.getText().split()) > 25:
|
if len(object.getText().split()) > 25:
|
||||||
text += " [...]"
|
text += " [...]"
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def searchable_text(object):
|
def searchable_text(object):
|
||||||
return object.getText(targetMimetype='text/plain')
|
return object.getText(targetMimetype='text/plain')
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def in_response_to(object):
|
def in_response_to(object):
|
||||||
# Always returns the content object the comment is added to.
|
# Always returns the content object the comment is added to.
|
||||||
# Do not confuse this with the in_reply_to attribute of a comment!
|
# Do not confuse this with the in_reply_to attribute of a comment!
|
||||||
return object.__parent__.__parent__.title_or_id()
|
return object.__parent__.__parent__.title_or_id()
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def effective(object):
|
def effective(object):
|
||||||
# the catalog index needs Zope DateTime instead of Python datetime
|
# the catalog index needs Zope DateTime instead of Python datetime
|
||||||
@ -103,6 +113,7 @@ def effective(object):
|
|||||||
object.creation_date.second,
|
object.creation_date.second,
|
||||||
'GMT')
|
'GMT')
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def created(object):
|
def created(object):
|
||||||
# the catalog index needs Zope DateTime instead of Python datetime
|
# the catalog index needs Zope DateTime instead of Python datetime
|
||||||
@ -114,6 +125,7 @@ def created(object):
|
|||||||
object.creation_date.second,
|
object.creation_date.second,
|
||||||
'GMT')
|
'GMT')
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def modified(object):
|
def modified(object):
|
||||||
# the catalog index needs Zope DateTime instead of Python datetime
|
# the catalog index needs Zope DateTime instead of Python datetime
|
||||||
@ -125,20 +137,25 @@ def modified(object):
|
|||||||
object.modification_date.second,
|
object.modification_date.second,
|
||||||
'GMT')
|
'GMT')
|
||||||
|
|
||||||
|
|
||||||
# Override the conversation indexers for comments
|
# Override the conversation indexers for comments
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def comments_total_comments(object):
|
def comments_total_comments(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def comments_last_comment_date(object):
|
def comments_last_comment_date(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def comments_commentators(object):
|
def comments_commentators(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
# Make sure comments don't inherit their container's UID
|
# Make sure comments don't inherit their container's UID
|
||||||
@indexer(IComment)
|
@indexer(IComment)
|
||||||
def UID(object):
|
def UID(object):
|
||||||
|
@ -9,7 +9,6 @@ from zope.component import getSiteManager
|
|||||||
from zope.component import queryUtility
|
from zope.component import queryUtility
|
||||||
|
|
||||||
from plone.app.testing import TEST_USER_ID, setRoles
|
from plone.app.testing import TEST_USER_ID, setRoles
|
||||||
from plone.app.testing import logout, login
|
|
||||||
|
|
||||||
from Products.MailHost.interfaces import IMailHost
|
from Products.MailHost.interfaces import IMailHost
|
||||||
from Products.CMFPlone.tests.utils import MockMailHost
|
from Products.CMFPlone.tests.utils import MockMailHost
|
||||||
@ -225,10 +224,12 @@ class TestModeratorNotificationUnit(unittest.TestCase):
|
|||||||
in msg)
|
in msg)
|
||||||
self.assertTrue('Comment text' in msg)
|
self.assertTrue('Comment text' in msg)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
'Approve comment:\nhttp://nohost/plone/doc1/++conversation++default/%s/@@moderat=\ne-publish-comment'
|
'Approve comment:\nhttp://nohost/plone/doc1/' +
|
||||||
|
'++conversation++default/%s/@@moderat=\ne-publish-comment'
|
||||||
% comment_id in msg)
|
% comment_id in msg)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
'Delete comment:\nhttp://nohost/plone/doc1/++conversation++default/%s/@@moderat=\ne-delete-comment'
|
'Delete comment:\nhttp://nohost/plone/doc1/' +
|
||||||
|
'++conversation++default/%s/@@moderat=\ne-delete-comment'
|
||||||
% comment_id in msg)
|
% comment_id in msg)
|
||||||
|
|
||||||
def test_notify_moderator_specific_address(self):
|
def test_notify_moderator_specific_address(self):
|
||||||
|
@ -4,10 +4,12 @@ from zope.component import queryUtility, createObject
|
|||||||
|
|
||||||
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.interfaces import ICommentingTool, IConversation
|
from plone.app.discussion.interfaces import ICommentingTool, IConversation
|
||||||
|
|
||||||
|
|
||||||
class ToolTest(unittest.TestCase):
|
class ToolTest(unittest.TestCase):
|
||||||
|
|
||||||
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||||
@ -34,8 +36,9 @@ class ToolTest(unittest.TestCase):
|
|||||||
# Check that the comment got indexed in the tool:
|
# Check that the comment got indexed in the tool:
|
||||||
tool = queryUtility(ICommentingTool)
|
tool = queryUtility(ICommentingTool)
|
||||||
comment = list(tool.searchResults())
|
comment = list(tool.searchResults())
|
||||||
self.assertTrue(len(comment) == 1, "There is only one comment, but we got"
|
self.assertTrue(len(comment) == 1,
|
||||||
" %s results in the search" % len(comment))
|
"There is only one comment, but we got"
|
||||||
|
" %s results in the search" % len(comment))
|
||||||
self.assertEqual(comment[0].Title, 'Jim on Document 1')
|
self.assertEqual(comment[0].Title, 'Jim on Document 1')
|
||||||
|
|
||||||
def test_unindexing(self):
|
def test_unindexing(self):
|
||||||
@ -45,5 +48,6 @@ class ToolTest(unittest.TestCase):
|
|||||||
# search returns only comments
|
# search returns only comments
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||||
|
Loading…
Reference in New Issue
Block a user