2 lines between top level functions/classes
This commit is contained in:
parent
4bc77a2831
commit
9066183ea9
@ -235,6 +235,7 @@ def notify_content_object(obj, event):
|
|||||||
'last_comment_date',
|
'last_comment_date',
|
||||||
'commentators'))
|
'commentators'))
|
||||||
|
|
||||||
|
|
||||||
def notify_content_object_deleted(obj, event):
|
def notify_content_object_deleted(obj, event):
|
||||||
"""Remove all comments of a content object when the content object has been
|
"""Remove all comments of a content object when the content object has been
|
||||||
deleted.
|
deleted.
|
||||||
@ -244,6 +245,7 @@ def notify_content_object_deleted(obj, event):
|
|||||||
while conversation:
|
while conversation:
|
||||||
del conversation[conversation.keys()[0]]
|
del conversation[conversation.keys()[0]]
|
||||||
|
|
||||||
|
|
||||||
def notify_comment_added(obj, event):
|
def notify_comment_added(obj, event):
|
||||||
""" Notify custom discussion events when a comment is added or replied
|
""" 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(ReplyAddedEvent(context, obj))
|
||||||
return notify(CommentAddedEvent(context, obj))
|
return notify(CommentAddedEvent(context, obj))
|
||||||
|
|
||||||
|
|
||||||
def notify_comment_removed(obj, event):
|
def notify_comment_removed(obj, event):
|
||||||
""" Notify custom discussion events when a comment or reply is removed
|
""" 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(ReplyRemovedEvent(context, obj))
|
||||||
return notify(CommentRemovedEvent(context, obj))
|
return notify(CommentRemovedEvent(context, obj))
|
||||||
|
|
||||||
|
|
||||||
def notify_content_object_moved(obj, event):
|
def notify_content_object_moved(obj, event):
|
||||||
"""Update all comments of a content object that has been moved.
|
"""Update all comments of a content object that has been moved.
|
||||||
"""
|
"""
|
||||||
|
@ -23,6 +23,7 @@ def execute_comment(event):
|
|||||||
"""
|
"""
|
||||||
execute(event.object, event)
|
execute(event.object, event)
|
||||||
|
|
||||||
|
|
||||||
class CommentSubstitution(BaseSubstitution):
|
class CommentSubstitution(BaseSubstitution):
|
||||||
""" Comment string substitution
|
""" Comment string substitution
|
||||||
"""
|
"""
|
||||||
@ -41,6 +42,7 @@ class CommentSubstitution(BaseSubstitution):
|
|||||||
"""
|
"""
|
||||||
return self.event.comment
|
return self.event.comment
|
||||||
|
|
||||||
|
|
||||||
class Id(CommentSubstitution):
|
class Id(CommentSubstitution):
|
||||||
""" Comment id string substitution
|
""" Comment id string substitution
|
||||||
"""
|
"""
|
||||||
@ -52,6 +54,7 @@ class Id(CommentSubstitution):
|
|||||||
"""
|
"""
|
||||||
return getattr(self.comment, 'comment_id', u'')
|
return getattr(self.comment, 'comment_id', u'')
|
||||||
|
|
||||||
|
|
||||||
class Text(CommentSubstitution):
|
class Text(CommentSubstitution):
|
||||||
""" Comment text
|
""" Comment text
|
||||||
"""
|
"""
|
||||||
@ -63,6 +66,7 @@ class Text(CommentSubstitution):
|
|||||||
"""
|
"""
|
||||||
return getattr(self.comment, 'text', u'')
|
return getattr(self.comment, 'text', u'')
|
||||||
|
|
||||||
|
|
||||||
class AuthorUserName(CommentSubstitution):
|
class AuthorUserName(CommentSubstitution):
|
||||||
""" Comment author user name string substitution
|
""" Comment author user name string substitution
|
||||||
"""
|
"""
|
||||||
@ -74,6 +78,7 @@ class AuthorUserName(CommentSubstitution):
|
|||||||
"""
|
"""
|
||||||
return getattr(self.comment, 'author_username', u'')
|
return getattr(self.comment, 'author_username', u'')
|
||||||
|
|
||||||
|
|
||||||
class AuthorFullName(CommentSubstitution):
|
class AuthorFullName(CommentSubstitution):
|
||||||
""" Comment author full name string substitution
|
""" Comment author full name string substitution
|
||||||
"""
|
"""
|
||||||
@ -85,6 +90,7 @@ class AuthorFullName(CommentSubstitution):
|
|||||||
"""
|
"""
|
||||||
return getattr(self.comment, 'author_name', u'')
|
return getattr(self.comment, 'author_name', u'')
|
||||||
|
|
||||||
|
|
||||||
class AuthorEmail(CommentSubstitution):
|
class AuthorEmail(CommentSubstitution):
|
||||||
""" Comment author email string substitution
|
""" Comment author email string substitution
|
||||||
"""
|
"""
|
||||||
|
@ -24,21 +24,25 @@ class DiscussionEvent(object):
|
|||||||
request = context.REQUEST
|
request = context.REQUEST
|
||||||
request.set('event', self)
|
request.set('event', self)
|
||||||
|
|
||||||
|
|
||||||
class CommentAddedEvent(DiscussionEvent):
|
class CommentAddedEvent(DiscussionEvent):
|
||||||
""" Event to be triggered when a Comment is added
|
""" Event to be triggered when a Comment is added
|
||||||
"""
|
"""
|
||||||
implements(ICommentAddedEvent)
|
implements(ICommentAddedEvent)
|
||||||
|
|
||||||
|
|
||||||
class CommentRemovedEvent(DiscussionEvent):
|
class CommentRemovedEvent(DiscussionEvent):
|
||||||
""" Event to be triggered when a Comment is removed
|
""" Event to be triggered when a Comment is removed
|
||||||
"""
|
"""
|
||||||
implements(ICommentRemovedEvent)
|
implements(ICommentRemovedEvent)
|
||||||
|
|
||||||
|
|
||||||
class ReplyAddedEvent(DiscussionEvent):
|
class ReplyAddedEvent(DiscussionEvent):
|
||||||
""" Event to be triggered when a Comment reply is added
|
""" Event to be triggered when a Comment reply is added
|
||||||
"""
|
"""
|
||||||
implements(IReplyAddedEvent)
|
implements(IReplyAddedEvent)
|
||||||
|
|
||||||
|
|
||||||
class ReplyRemovedEvent(DiscussionEvent):
|
class ReplyRemovedEvent(DiscussionEvent):
|
||||||
""" Event to be triggered when a Comment reply is removed
|
""" Event to be triggered when a Comment reply is removed
|
||||||
"""
|
"""
|
||||||
|
@ -371,22 +371,27 @@ class ICommentingTool(Interface):
|
|||||||
# Custom events
|
# Custom events
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
class IDiscussionEvent(IObjectEvent):
|
class IDiscussionEvent(IObjectEvent):
|
||||||
""" Discussion custom event
|
""" Discussion custom event
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class ICommentAddedEvent(IDiscussionEvent):
|
class ICommentAddedEvent(IDiscussionEvent):
|
||||||
""" Comment added
|
""" Comment added
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class ICommentRemovedEvent(IDiscussionEvent):
|
class ICommentRemovedEvent(IDiscussionEvent):
|
||||||
""" Comment removed
|
""" Comment removed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class IReplyAddedEvent(IDiscussionEvent):
|
class IReplyAddedEvent(IDiscussionEvent):
|
||||||
""" Comment reply added
|
""" Comment reply added
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class IReplyRemovedEvent(IDiscussionEvent):
|
class IReplyRemovedEvent(IDiscussionEvent):
|
||||||
""" Comment reply removed
|
""" Comment reply removed
|
||||||
"""
|
"""
|
||||||
|
@ -44,7 +44,6 @@ class CommentContentRulesTest(unittest.TestCase):
|
|||||||
conversation = IConversation(self.document)
|
conversation = IConversation(self.document)
|
||||||
conversation.addComment(comment)
|
conversation.addComment(comment)
|
||||||
|
|
||||||
|
|
||||||
def testEventTypesMarked(self):
|
def testEventTypesMarked(self):
|
||||||
self.assertTrue(IRuleEventType.providedBy(ICommentAddedEvent))
|
self.assertTrue(IRuleEventType.providedBy(ICommentAddedEvent))
|
||||||
self.assertTrue(IRuleEventType.providedBy(ICommentRemovedEvent))
|
self.assertTrue(IRuleEventType.providedBy(ICommentRemovedEvent))
|
||||||
|
@ -27,20 +27,29 @@ class EventsRegistry(object):
|
|||||||
#
|
#
|
||||||
# Fake event handlers
|
# Fake event handlers
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
def comment_added(doc, evt):
|
def comment_added(doc, evt):
|
||||||
EventsRegistry.commentAdded = True
|
EventsRegistry.commentAdded = True
|
||||||
|
|
||||||
|
|
||||||
def comment_removed(doc, evt):
|
def comment_removed(doc, evt):
|
||||||
EventsRegistry.commentRemoved = True
|
EventsRegistry.commentRemoved = True
|
||||||
|
|
||||||
|
|
||||||
def reply_added(doc, evt):
|
def reply_added(doc, evt):
|
||||||
EventsRegistry.replyAdded = True
|
EventsRegistry.replyAdded = True
|
||||||
|
|
||||||
|
|
||||||
def reply_removed(doc, evt):
|
def reply_removed(doc, evt):
|
||||||
EventsRegistry.replyRemoved = True
|
EventsRegistry.replyRemoved = True
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Tests
|
# Tests
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
class CommentEventsTest(unittest.TestCase):
|
class CommentEventsTest(unittest.TestCase):
|
||||||
""" Test custom comments events
|
""" Test custom comments events
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user