src/pyams_content/features/review/interfaces.py
changeset 238 2dc445ad2cf5
child 313 2e71fb238b1c
equal deleted inserted replaced
237:ccd42b19051a 238:2dc445ad2cf5
       
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     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
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from zope.annotation.interfaces import IAttributeAnnotatable
       
    20 from zope.container.interfaces import IContainer, IContained
       
    21 from zope.interface.interfaces import IObjectEvent, ObjectEvent
       
    22 
       
    23 # import packages
       
    24 from pyams_security.schema import Principal, PrincipalsSet
       
    25 from zope.container.constraints import contains, containers
       
    26 from zope.interface import implementer, Interface, Attribute
       
    27 from zope.schema import Text, Choice, Datetime
       
    28 
       
    29 from pyams_content import _
       
    30 
       
    31 
       
    32 COMMENT_TYPES = {'request': _("Review request"),
       
    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
       
    49 
       
    50 
       
    51 class IReviewComment(IContained, IAttributeAnnotatable):
       
    52     """Review comment interface"""
       
    53 
       
    54     containers('.IReviewComments')
       
    55 
       
    56     owner = Principal(title=_("Comment writer"),
       
    57                       required=True)
       
    58 
       
    59     comment = Text(title=_("Comment body"),
       
    60                    required=True)
       
    61 
       
    62     comment_type = Choice(title=_("Comment type"),
       
    63                           values=COMMENT_TYPES.keys(),
       
    64                           required=True,
       
    65                           default='comment')
       
    66 
       
    67     creation_date = Datetime(title=_("Creation date"),
       
    68                              required=False)
       
    69 
       
    70 
       
    71 REVIEW_COMMENTS_ANNOTATION_KEY = 'pyams_content.review_comments'
       
    72 
       
    73 
       
    74 class IReviewComments(IContainer):
       
    75     """Review comments container interface"""
       
    76 
       
    77     contains(IReviewComment)
       
    78 
       
    79     reviewers = PrincipalsSet(title=_("Reviewers list"),
       
    80                               description=_("List of principals which reviewed the comment"),
       
    81                               required=False)
       
    82 
       
    83     def clear(self):
       
    84         """Remove all comments"""
       
    85 
       
    86     def add_comment(self, comment):
       
    87         """Add given comment to list"""
       
    88 
       
    89 
       
    90 class IReviewManager(Interface):
       
    91     """Content review interface"""
       
    92 
       
    93     def ask_review(self, reviewers, comment, notify=True):
       
    94         """Ask for content review"""
       
    95 
       
    96 
       
    97 class IReviewTarget(Interface):
       
    98     """Review target marker interface
       
    99 
       
   100     This interface is used to mark contents which can handle review.
       
   101     """