black
This commit is contained in:
@@ -25,7 +25,7 @@ MAX_DESCRIPTION = 25
|
||||
def total_comments(object):
|
||||
# Total number of comments on a conversation
|
||||
# Indexers won't work on old discussion items
|
||||
if object.meta_type != 'Discussion Item':
|
||||
if object.meta_type != "Discussion Item":
|
||||
try:
|
||||
conversation = IConversation(object)
|
||||
return conversation.total_comments()
|
||||
@@ -39,7 +39,7 @@ def total_comments(object):
|
||||
def last_comment_date(object):
|
||||
# Date of the latest comment on a conversation
|
||||
# Indexers won't work on old discussion items
|
||||
if object.meta_type != 'Discussion Item':
|
||||
if object.meta_type != "Discussion Item":
|
||||
try:
|
||||
conversation = IConversation(object)
|
||||
return conversation.last_comment_date
|
||||
@@ -53,7 +53,7 @@ def last_comment_date(object):
|
||||
def commentators(object):
|
||||
# List of commentators on a conversation
|
||||
# Indexers won't work on old discussion items
|
||||
if object.meta_type != 'Discussion Item':
|
||||
if object.meta_type != "Discussion Item":
|
||||
try:
|
||||
conversation = IConversation(object)
|
||||
return conversation.public_commentators
|
||||
@@ -62,6 +62,7 @@ def commentators(object):
|
||||
# implemented an adapter for it
|
||||
pass
|
||||
|
||||
|
||||
# Comment Indexers
|
||||
|
||||
|
||||
@@ -76,24 +77,24 @@ def creator(object):
|
||||
return
|
||||
value = safe_unicode(object.creator)
|
||||
if six.PY2:
|
||||
return value.encode('utf8')
|
||||
return value.encode("utf8")
|
||||
return value
|
||||
|
||||
|
||||
@indexer(IComment)
|
||||
def description(object):
|
||||
# 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:
|
||||
text += ' [...]'
|
||||
text += " [...]"
|
||||
return text
|
||||
|
||||
|
||||
@indexer(IComment)
|
||||
def searchable_text(object):
|
||||
return object.getText(targetMimetype='text/plain')
|
||||
return object.getText(targetMimetype="text/plain")
|
||||
|
||||
|
||||
@indexer(IComment)
|
||||
@@ -107,42 +108,42 @@ def in_response_to(object):
|
||||
def effective(object):
|
||||
# the catalog index needs Zope DateTime instead of Python datetime
|
||||
return DateTime(
|
||||
object.creation_date.year,
|
||||
object.creation_date.month,
|
||||
object.creation_date.day,
|
||||
object.creation_date.hour,
|
||||
object.creation_date.minute,
|
||||
object.creation_date.second,
|
||||
'GMT',
|
||||
)
|
||||
object.creation_date.year,
|
||||
object.creation_date.month,
|
||||
object.creation_date.day,
|
||||
object.creation_date.hour,
|
||||
object.creation_date.minute,
|
||||
object.creation_date.second,
|
||||
"GMT",
|
||||
)
|
||||
|
||||
|
||||
@indexer(IComment)
|
||||
def created(object):
|
||||
# the catalog index needs Zope DateTime instead of Python datetime
|
||||
return DateTime(
|
||||
object.creation_date.year,
|
||||
object.creation_date.month,
|
||||
object.creation_date.day,
|
||||
object.creation_date.hour,
|
||||
object.creation_date.minute,
|
||||
object.creation_date.second,
|
||||
'GMT',
|
||||
)
|
||||
object.creation_date.year,
|
||||
object.creation_date.month,
|
||||
object.creation_date.day,
|
||||
object.creation_date.hour,
|
||||
object.creation_date.minute,
|
||||
object.creation_date.second,
|
||||
"GMT",
|
||||
)
|
||||
|
||||
|
||||
@indexer(IComment)
|
||||
def modified(object):
|
||||
# the catalog index needs Zope DateTime instead of Python datetime
|
||||
return DateTime(
|
||||
object.modification_date.year,
|
||||
object.modification_date.month,
|
||||
object.modification_date.day,
|
||||
object.modification_date.hour,
|
||||
object.modification_date.minute,
|
||||
object.modification_date.second,
|
||||
'GMT',
|
||||
)
|
||||
object.modification_date.year,
|
||||
object.modification_date.month,
|
||||
object.modification_date.day,
|
||||
object.modification_date.hour,
|
||||
object.modification_date.minute,
|
||||
object.modification_date.second,
|
||||
"GMT",
|
||||
)
|
||||
|
||||
|
||||
# Override the conversation indexers for comments
|
||||
|
||||
Reference in New Issue
Block a user