7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
10 # FOR A PARTICULAR PURPOSE. |
10 # FOR A PARTICULAR PURPOSE. |
11 # |
11 # |
|
12 from zope.interface.interfaces import IObjectEvent, ObjectEvent |
12 |
13 |
13 __docformat__ = 'restructuredtext' |
14 __docformat__ = 'restructuredtext' |
14 |
15 |
15 |
16 |
16 # import standard library |
17 # import standard library |
18 # import interfaces |
19 # import interfaces |
19 from zope.annotation.interfaces import IAttributeAnnotatable |
20 from zope.annotation.interfaces import IAttributeAnnotatable |
20 from zope.container.interfaces import IContainer, IContained |
21 from zope.container.interfaces import IContainer, IContained |
21 |
22 |
22 # import packages |
23 # import packages |
23 from pyams_security.schema import Principal |
24 from pyams_security.schema import Principal, PrincipalsSet |
24 from zope.container.constraints import contains, containers |
25 from zope.container.constraints import contains, containers |
25 from zope.interface import Interface |
26 from zope.interface import implementer, Interface, Attribute |
26 from zope.schema import Text, Choice, Datetime |
27 from zope.schema import Text, Choice, Datetime |
27 |
28 |
28 from pyams_content import _ |
29 from pyams_content import _ |
29 |
30 |
30 |
31 |
31 COMMENT_TYPES = {'request': _("Review request"), |
32 COMMENT_TYPES = {'request': _("Review request"), |
32 'comment': _("Reviewer comment")} |
33 'comment': _("Reviewer comment")} |
|
34 |
|
35 |
|
36 class ICommentAddedEvent(IObjectEvent): |
|
37 """Comment added event interface""" |
|
38 |
|
39 comment = Attribute("New comment") |
|
40 |
|
41 |
|
42 @implementer(ICommentAddedEvent) |
|
43 class CommentAddedEvent(ObjectEvent): |
|
44 """Comment added event""" |
|
45 |
|
46 def __init__(self, object, comment): |
|
47 super(CommentAddedEvent, self).__init__(object) |
|
48 self.comment = comment |
33 |
49 |
34 |
50 |
35 class IReviewComment(IContained, IAttributeAnnotatable): |
51 class IReviewComment(IContained, IAttributeAnnotatable): |
36 """Review comment interface""" |
52 """Review comment interface""" |
37 |
53 |
58 class IReviewComments(IContainer): |
74 class IReviewComments(IContainer): |
59 """Review comments container interface""" |
75 """Review comments container interface""" |
60 |
76 |
61 contains(IReviewComment) |
77 contains(IReviewComment) |
62 |
78 |
|
79 reviewers = PrincipalsSet(title=_("Reviewers list"), |
|
80 description=_("List of principals which reviewed the comment"), |
|
81 required=False) |
|
82 |
63 def clear(self): |
83 def clear(self): |
64 """Remove all comments""" |
84 """Remove all comments""" |
65 |
85 |
66 def add_comment(self, comment): |
86 def add_comment(self, comment): |
67 """Add given comment to list""" |
87 """Add given comment to list""" |