Skip to content

Commit

Permalink
Additional (optional) workflow: "Comment Multiple State Review Workflow"
Browse files Browse the repository at this point in the history
Moderator is not forced to delete a comment or to let it pending:
Workflow has two more states "rejected" and "spam" to existing review workflow.
Moderation view extended showing all states. Filter by state.
  • Loading branch information
ksuess committed Jan 8, 2020
1 parent f7b8335 commit 084d289
Show file tree
Hide file tree
Showing 17 changed files with 682 additions and 532 deletions.
3 changes: 3 additions & 0 deletions news/164.enhancement
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Additional optional workflow: workflow with two more states: rejected and spam,
added to existing states pending and published. Moderation view extended to handle four workflow states.
[ksuess]
11 changes: 6 additions & 5 deletions plone/app/discussion/browser/comments.pt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
portrait_url python:view.get_commenter_portrait(reply.author_username);
review_state python:wtool.getInfoFor(reply, 'review_state', 'none');
canEdit python:view.can_edit(reply);
canDelete python:view.can_delete(reply)"
tal:attributes="class python:'comment replyTreeLevel'+str(depth)+' state-'+str(review_state);
canDelete python:view.can_delete(reply);
colorclass python:lambda x: 'state-private' if x=='rejected' else ('state-internal' if x=='spam' else 'state-'+x);"
tal:attributes="class python:'comment replyTreeLevel{depth} {state}'.format(depth= depth, state=colorclass(review_state));
id string:${reply/getId}"
tal:condition="python:canReview or review_state == 'published'">

Expand Down Expand Up @@ -119,7 +120,7 @@
<tal:edit tal:condition="python:isEditCommentAllowed and canEdit">
<!-- plone 5 will have auth_token available
so we'll use modal pattern -->
<a class="commentactionsform pat-plone-modal context"
<a class="pat-plone-modal context"
tal:condition="auth_token"
tal:attributes="href string:${reply/absolute_url}/@@edit-comment?_authenticator=${auth_token}"
i18n:translate="Edit">Edit</a>
Expand All @@ -146,10 +147,10 @@
class="commentactionsform"
tal:condition="canReview"
tal:repeat="action reply_dict/actions|nothing"
tal:attributes="action string:${reply/absolute_url}/@@moderate-publish-comment;
tal:attributes="action string:${reply/absolute_url}/@@transmit-comment;
name action/id">
<input type="hidden" name="workflow_action" tal:attributes="value action/id" />
<input name="form.button.PublishComment"
<input name="form.button.TransmitComment"
class="context"
type="submit"
tal:attributes="value action/title"
Expand Down
14 changes: 3 additions & 11 deletions plone/app/discussion/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,15 @@
permission="plone.app.discussion.DeleteOwnComments"
/>

<!-- Publish comment view -->
<!-- Comment Transition -->
<browser:page
for="plone.app.discussion.interfaces.IComment"
name="moderate-publish-comment"
name="transmit-comment"
layer="..interfaces.IDiscussionLayer"
class=".moderation.PublishComment"
class=".moderation.CommentTransition"
permission="plone.app.discussion.ReviewComments"
/>

<!-- Reject comment view -->
<browser:page
for="plone.app.discussion.interfaces.IComment"
name="moderate-reject-comment"
layer="..interfaces.IDiscussionLayer"
class=".moderation.RejectComment"
permission="plone.app.discussion.ReviewComments"
/>

<!-- Comments viewlet -->
<browser:viewlet
Expand Down
9 changes: 6 additions & 3 deletions plone/app/discussion/browser/controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,18 @@ def mailhost_warning(self):
return True

def custom_comment_workflow_warning(self):
"""Returns a warning string if a custom comment workflow is enabled.
"""
"""Return True if a custom comment workflow is enabled."""
wftool = getToolByName(self.context, 'portal_workflow', None)
workflow_chain = wftool.getChainForPortalType('Discussion Item')
one_state_workflow_enabled = \
'comment_one_state_workflow' in workflow_chain
comment_review_workflow_enabled = \
'comment_review_workflow' in workflow_chain
if one_state_workflow_enabled or comment_review_workflow_enabled:
comment_multiple_state_review_workflow = \
'comment_multiple_state_review_workflow' in workflow_chain
if one_state_workflow_enabled \
or comment_review_workflow_enabled \
or comment_multiple_state_review_workflow:
return
return True

Expand Down
8 changes: 4 additions & 4 deletions plone/app/discussion/browser/javascripts/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ require([ // jshint ignore:line


/**********************************************************************
* Publish a single comment.
* Transmit a single comment.
**********************************************************************/
$('input[name="form.button.PublishComment"]').on('click', function () {
$('input[name="form.button.TransmitComment"]').on('click', function () {
var trigger = this;
var form = $(this).parents('form');
var data = $(form).serialize();
Expand All @@ -176,7 +176,7 @@ require([ // jshint ignore:line
context: trigger,
success: function (msg) { // jshint ignore:line
// remove button (trigger object can't be directly removed)
form.find('input[name="form.button.PublishComment"]').remove();
form.find('input[name="form.button.TransmitComment"]').remove();
form.parents('.state-pending').toggleClass('state-pending').toggleClass('state-published');
},
error: function (msg) { // jshint ignore:line
Expand All @@ -201,7 +201,7 @@ require([ // jshint ignore:line
/**********************************************************************
* Delete a comment and its answers.
**********************************************************************/
$('input[name="form.button.DeleteComment"]').on('click', function () {
$('input[name="form.button.DeleteCommentComment"]').on('click', function () {
var trigger = this;
var form = $(this).parents('form');
var data = $(form).serialize();
Expand Down
Loading

0 comments on commit 084d289

Please sign in to comment.