2 lines between top level functions/classes

This commit is contained in:
Gil Forcada 2015-05-03 08:22:51 +02:00
parent 4bc77a2831
commit 9066183ea9
6 changed files with 28 additions and 1 deletions

View File

@ -235,6 +235,7 @@ def notify_content_object(obj, event):
'last_comment_date',
'commentators'))
def notify_content_object_deleted(obj, event):
"""Remove all comments of a content object when the content object has been
deleted.
@ -244,6 +245,7 @@ def notify_content_object_deleted(obj, event):
while conversation:
del conversation[conversation.keys()[0]]
def notify_comment_added(obj, event):
""" Notify custom discussion events when a comment is added or replied
"""
@ -253,6 +255,7 @@ def notify_comment_added(obj, event):
return notify(ReplyAddedEvent(context, obj))
return notify(CommentAddedEvent(context, obj))
def notify_comment_removed(obj, event):
""" Notify custom discussion events when a comment or reply is removed
"""
@ -262,6 +265,7 @@ def notify_comment_removed(obj, event):
return notify(ReplyRemovedEvent(context, obj))
return notify(CommentRemovedEvent(context, obj))
def notify_content_object_moved(obj, event):
"""Update all comments of a content object that has been moved.
"""

View File

@ -23,6 +23,7 @@ def execute_comment(event):
"""
execute(event.object, event)
class CommentSubstitution(BaseSubstitution):
""" Comment string substitution
"""
@ -41,6 +42,7 @@ class CommentSubstitution(BaseSubstitution):
"""
return self.event.comment
class Id(CommentSubstitution):
""" Comment id string substitution
"""
@ -52,6 +54,7 @@ class Id(CommentSubstitution):
"""
return getattr(self.comment, 'comment_id', u'')
class Text(CommentSubstitution):
""" Comment text
"""
@ -63,6 +66,7 @@ class Text(CommentSubstitution):
"""
return getattr(self.comment, 'text', u'')
class AuthorUserName(CommentSubstitution):
""" Comment author user name string substitution
"""
@ -74,6 +78,7 @@ class AuthorUserName(CommentSubstitution):
"""
return getattr(self.comment, 'author_username', u'')
class AuthorFullName(CommentSubstitution):
""" Comment author full name string substitution
"""
@ -85,6 +90,7 @@ class AuthorFullName(CommentSubstitution):
"""
return getattr(self.comment, 'author_name', u'')
class AuthorEmail(CommentSubstitution):
""" Comment author email string substitution
"""

View File

@ -24,21 +24,25 @@ class DiscussionEvent(object):
request = context.REQUEST
request.set('event', self)
class CommentAddedEvent(DiscussionEvent):
""" Event to be triggered when a Comment is added
"""
implements(ICommentAddedEvent)
class CommentRemovedEvent(DiscussionEvent):
""" Event to be triggered when a Comment is removed
"""
implements(ICommentRemovedEvent)
class ReplyAddedEvent(DiscussionEvent):
""" Event to be triggered when a Comment reply is added
"""
implements(IReplyAddedEvent)
class ReplyRemovedEvent(DiscussionEvent):
""" Event to be triggered when a Comment reply is removed
"""

View File

@ -371,22 +371,27 @@ class ICommentingTool(Interface):
# Custom events
#
class IDiscussionEvent(IObjectEvent):
""" Discussion custom event
"""
class ICommentAddedEvent(IDiscussionEvent):
""" Comment added
"""
class ICommentRemovedEvent(IDiscussionEvent):
""" Comment removed
"""
class IReplyAddedEvent(IDiscussionEvent):
""" Comment reply added
"""
class IReplyRemovedEvent(IDiscussionEvent):
""" Comment reply removed
"""

View File

@ -44,7 +44,6 @@ class CommentContentRulesTest(unittest.TestCase):
conversation = IConversation(self.document)
conversation.addComment(comment)
def testEventTypesMarked(self):
self.assertTrue(IRuleEventType.providedBy(ICommentAddedEvent))
self.assertTrue(IRuleEventType.providedBy(ICommentRemovedEvent))

View File

@ -27,20 +27,29 @@ class EventsRegistry(object):
#
# Fake event handlers
#
def comment_added(doc, evt):
EventsRegistry.commentAdded = True
def comment_removed(doc, evt):
EventsRegistry.commentRemoved = True
def reply_added(doc, evt):
EventsRegistry.replyAdded = True
def reply_removed(doc, evt):
EventsRegistry.replyRemoved = True
#
# Tests
#
class CommentEventsTest(unittest.TestCase):
""" Test custom comments events
"""