# HG changeset patch # User Thierry Florac # Date 1512726410 -3600 # Node ID 2e71fb238b1cd1845a7f78f82e722ecf235e706d # Parent cc13bd3548c3e2331e1955f16f6ab773dcb2c2db Updated review interface diff -r cc13bd3548c3 -r 2e71fb238b1c src/pyams_content/features/review/__init__.py --- a/src/pyams_content/features/review/__init__.py Fri Dec 08 10:46:16 2017 +0100 +++ b/src/pyams_content/features/review/__init__.py Fri Dec 08 10:46:50 2017 +0100 @@ -39,7 +39,7 @@ from pyams_security.principal import MissingPrincipal from pyams_utils.adapter import adapter_config, ContextAdapter from pyams_utils.container import BTreeOrderedContainer -from pyams_utils.registry import query_utility +from pyams_utils.registry import query_utility, get_utility from pyams_utils.request import check_request, query_request from pyams_utils.url import absolute_url from pyramid.events import subscriber @@ -58,14 +58,20 @@ """Review comment persistent class""" owner = FieldProperty(IReviewComment['owner']) + reviewers = FieldProperty(IReviewComment['reviewers']) + comment_type = FieldProperty(IReviewComment['comment_type']) comment = FieldProperty(IReviewComment['comment']) - comment_type = FieldProperty(IReviewComment['comment_type']) + is_reviewer_comment = FieldProperty(IReviewComment['is_reviewer_comment']) creation_date = FieldProperty(IReviewComment['creation_date']) - def __init__(self, owner, comment, comment_type='comment'): + def __init__(self, owner, comment, comment_type='comment', reviewers=None): self.owner = owner self.comment = comment self.comment_type = comment_type + security = get_utility(ISecurityManager) + if reviewers: + self.reviewers = ', '.join((principal.title for principal in ( + security.get_principal(reviewer) for reviewer in reviewers))) self.creation_date = datetime.utcnow() @@ -131,7 +137,7 @@ request = check_request() translate = request.localizer.translate # initialize mailer - security = query_utility(ISecurityManager) + security = get_utility(ISecurityManager) settings = INotificationSettings(security) sender_name = request.principal.title if request.principal is not None else settings.sender_name sender_address = settings.sender_email @@ -176,8 +182,9 @@ roles.readers = readers # add comment review_comment = ReviewComment(owner=request.principal.id, - comment=comment, - comment_type='request') + comment_type='request', + comment=translate(_("Request comment: {comment}")).format(comment=comment), + reviewers=reviewers) IReviewComments(self.context).add_comment(review_comment) # return notifications count return notifications @@ -193,7 +200,6 @@ except ImportError: pass else: - @subscriber(ICommentAddedEvent) def handle_new_comment(event): """Handle new review comment""" diff -r cc13bd3548c3 -r 2e71fb238b1c src/pyams_content/features/review/interfaces.py --- a/src/pyams_content/features/review/interfaces.py Fri Dec 08 10:46:16 2017 +0100 +++ b/src/pyams_content/features/review/interfaces.py Fri Dec 08 10:46:50 2017 +0100 @@ -24,7 +24,7 @@ from pyams_security.schema import Principal, PrincipalsSet from zope.container.constraints import contains, containers from zope.interface import implementer, Interface, Attribute -from zope.schema import Text, Choice, Datetime +from zope.schema import Text, TextLine, Choice, Datetime, Bool from pyams_content import _ @@ -56,14 +56,21 @@ owner = Principal(title=_("Comment writer"), required=True) - comment = Text(title=_("Comment body"), - required=True) + reviewers = TextLine(title=_("Content reviewers"), + required=False) comment_type = Choice(title=_("Comment type"), values=COMMENT_TYPES.keys(), required=True, default='comment') + comment = Text(title=_("Comment body"), + required=True) + + is_reviewer_comment = Bool(title=_("Reviewer comment?"), + required=True, + default=False) + creation_date = Datetime(title=_("Creation date"), required=False) diff -r cc13bd3548c3 -r 2e71fb238b1c src/pyams_content/features/review/zmi/__init__.py --- a/src/pyams_content/features/review/zmi/__init__.py Fri Dec 08 10:46:16 2017 +0100 +++ b/src/pyams_content/features/review/zmi/__init__.py Fri Dec 08 10:46:50 2017 +0100 @@ -18,6 +18,7 @@ # import interfaces from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION, COMMENT_CONTENT_PERMISSION from pyams_content.features.review.interfaces import IReviewManager, IReviewComments, IReviewTarget +from pyams_content.shared.common import IWfSharedContentRoles from pyams_security.interfaces import ISecurityManager from pyams_security.interfaces.profile import IPublicProfile from pyams_skin.interfaces.viewlet import IContextActions, IWidgetTitleViewletManager @@ -268,9 +269,12 @@ return {'status': 'error', 'message': translate(_("Message is mandatory!"))} # add new comment + comments = IReviewComments(request.context) comment = ReviewComment(owner=request.principal.id, comment=request.params.get('comment')) - comments = IReviewComments(request.context) + roles = IWfSharedContentRoles(request.context, None) + if roles is not None: + comment.is_reviewer_comment = comment.owner in (roles.readers or ()) comments.add_comment(comment) # return comment infos profile = IPublicProfile(request.principal) diff -r cc13bd3548c3 -r 2e71fb238b1c src/pyams_content/features/review/zmi/templates/review-comments-json.pt --- a/src/pyams_content/features/review/zmi/templates/review-comments-json.pt Fri Dec 08 10:46:16 2017 +0100 +++ b/src/pyams_content/features/review/zmi/templates/review-comments-json.pt Fri Dec 08 10:46:50 2017 +0100 @@ -15,7 +15,7 @@ i18n:translate="">Review query from  Owner - +   (as reviewer) @@ -25,6 +25,11 @@ tal:attributes="title view.get_date(comment)" tal:content="view.get_age(comment).lower()">age +
+ Selected reviewers:  +
+
diff -r cc13bd3548c3 -r 2e71fb238b1c src/pyams_content/features/review/zmi/templates/review-comments.pt --- a/src/pyams_content/features/review/zmi/templates/review-comments.pt Fri Dec 08 10:46:16 2017 +0100 +++ b/src/pyams_content/features/review/zmi/templates/review-comments.pt Fri Dec 08 10:46:50 2017 +0100 @@ -32,7 +32,7 @@ i18n:translate="">Review query from 
Owner - +   (as reviewer) @@ -42,6 +42,11 @@ tal:attributes="title view.get_date(comment)" tal:content="view.get_age(comment).lower()">age +
+ Selected reviewers:  + +