Added event for new comments
authorThierry Florac <thierry.florac@onf.fr>
Fri, 08 Jul 2016 15:39:08 +0200
changeset 52 d9400e3ca85d
parent 51 5f6b98be4c04
child 53 4acef7070de7
Added event for new comments
src/pyams_content/interfaces/review.py
--- a/src/pyams_content/interfaces/review.py	Fri Jul 08 15:36:12 2016 +0200
+++ b/src/pyams_content/interfaces/review.py	Fri Jul 08 15:39:08 2016 +0200
@@ -9,6 +9,7 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from zope.interface.interfaces import IObjectEvent, ObjectEvent
 
 __docformat__ = 'restructuredtext'
 
@@ -20,9 +21,9 @@
 from zope.container.interfaces import IContainer, IContained
 
 # import packages
-from pyams_security.schema import Principal
+from pyams_security.schema import Principal, PrincipalsSet
 from zope.container.constraints import contains, containers
-from zope.interface import Interface
+from zope.interface import implementer, Interface, Attribute
 from zope.schema import Text, Choice, Datetime
 
 from pyams_content import _
@@ -32,6 +33,21 @@
                  'comment': _("Reviewer comment")}
 
 
+class ICommentAddedEvent(IObjectEvent):
+    """Comment added event interface"""
+
+    comment = Attribute("New comment")
+
+
+@implementer(ICommentAddedEvent)
+class CommentAddedEvent(ObjectEvent):
+    """Comment added event"""
+
+    def __init__(self, object, comment):
+        super(CommentAddedEvent, self).__init__(object)
+        self.comment = comment
+
+
 class IReviewComment(IContained, IAttributeAnnotatable):
     """Review comment interface"""
 
@@ -60,6 +76,10 @@
 
     contains(IReviewComment)
 
+    reviewers = PrincipalsSet(title=_("Reviewers list"),
+                              description=_("List of principals which reviewed the comment"),
+                              required=False)
+
     def clear(self):
         """Remove all comments"""