Additional view for approved comments

linked in "moderate comments" view
This commit is contained in:
Katja Suess 2019-09-07 11:31:53 +02:00
parent ddf0ac0314
commit 1b7d9fcb16
7 changed files with 189 additions and 2 deletions

2
news/159.enhancement Normal file
View File

@ -0,0 +1,2 @@
Additional view for approved comments
[ksuess]

View File

@ -0,0 +1,129 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="plone">
<body>
<metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main"
tal:define="toLocalizedTime nocall:context/@@plone/toLocalizedTime;
items view/comments;
filter view/filter|nothing;
Batch python:modules['Products.CMFPlone'].Batch;
b_size python:30;
b_start python:0;
b_start request/b_start | b_start;
moderation_enabled view/moderation_enabled;">
<script type="text/javascript"
tal:attributes="src string:${context/portal_url}/++plone++plone.app.discussion.javascripts/moderation.js">
</script>
<h1 class="documentFirstHeading" i18n:translate="heading_comments_approved">
Comments approved
</h1>
<div class="portalMessage warning"
tal:condition="not: view/moderation_enabled">
<strong i18n:translate="">Warning</strong>
<span tal:omit-tag="" i18n:translate="message_moderation_disabled">
Moderation workflow is disabled. You have to
<a i18n:name="enable_comment_workflow"
i18n:translate="message_enable_comment_workflow" href=""
tal:attributes="href string:${context/portal_url}/@@content-controlpanel?type_id=Discussion Item">
enable the 'Comment Review Workflow' for the Comment content
type</a> before you can moderate comments here.
</span>
</div>
<form tal:condition="not:items">
<fieldset id="fieldset-moderate-comments" class="formPanel">
<p id="no-comments-message" i18n:translate="message_no_comments_approved">
No comments approved
</p>
</fieldset>
</form>
<form method="post"
action="#"
tal:condition="items"
tal:define="batch python:Batch(items, b_size, int(b_start), orphan=1);">
<fieldset id="fieldset-moderate-comments" class="formPanel">
<div metal:use-macro="here/batch_macros/macros/navigation" />
<table id="review-comments" class="listing">
<thead>
<tr>
<th class="nosort" i18n:translate="heading_commenter">Commenter</th>
<th class="nosort" i18n:translate="heading_date">Date</th>
<th class="nosort" i18n:translate="heading_in_reponse_to">In Response To</th>
<th class="nosort" i18n:translate="heading_comment">Comment</th>
<th class="nosort" i18n:translate="heading_approvedby">Approved by</th>
<th class="nosort" i18n:translate="heading_action">Action</th>
</tr>
</thead>
<tbody>
<tal:block repeat="item batch">
<tr class="commentrow"
tal:define="even repeat/item/even;
email python:getattr(item.getObject(), 'author_email');
item_url item/getURL;"
tal:attributes="class python: even and 'odd' or 'even'">
<td>
<span tal:content="python:item.author_name or item.Creator">Name</span>
<tal:email tal:condition="email">
<br/>
<a tal:attributes="href string:mailto:$email;"
tal:content="email">Email
</a>
</tal:email>
</td>
<td tal:content="python:toLocalizedTime(item.created, long_format=1)"/>
<td>
<a tal:attributes="href item_url"
tal:content="item/in_response_to" />
</td>
<td>
<span tal:replace="item/Description" />
<a href=""
tal:attributes="href string:$item_url/getText"
tal:condition="python:item.Description.endswith('[...]')"
i18n:translate="label_show_full_comment_text"
class="show-full-comment-text">show full comment text</a>
</td>
<td>
<span class="last-history-entry"
tal:attributes="data-href string:$item_url/@@historyview">
last history entry
</span>
</td>
<td class="actions">
<input type="hidden" name="selected_obj_paths:list" value="#"
tal:attributes="value item/getURL" />
<input id=""
class="destructive comment-delete-button"
type="submit"
value="Delete"
name="form.button.Delete"
i18n:attributes="value label_delete;"
tal:attributes="id item/id"
/>
</td>
</tr>
</tal:block>
</tbody>
</table>
<div metal:use-macro="here/batch_macros/macros/navigation" />
</fieldset>
</form>
</tal:main-macro>
</metal:main>
</body>
</html>

View File

@ -29,6 +29,23 @@
permission="plone.app.discussion.ReviewComments"
/>
<!-- Approved comments view -->
<browser:page
for="Products.CMFCore.interfaces.ISiteRoot"
name="comments-approved"
layer="..interfaces.IDiscussionLayer"
class=".moderation.ApprovedView"
permission="plone.app.discussion.ReviewComments"
/>
<browser:page
for="plone.app.layout.navigation.interfaces.INavigationRoot"
name="comments-approved"
layer="..interfaces.IDiscussionLayer"
class=".moderation.ApprovedView"
permission="plone.app.discussion.ReviewComments"
/>
<!-- Moderation bulk actions view -->
<browser:page
for="Products.CMFCore.interfaces.ISiteRoot"

View File

@ -165,6 +165,16 @@ require([ // jshint ignore:line
});
});
/**********************************************************************
* Comments approved: Load history for approved date.
**********************************************************************/
$(".last-history-entry").each(function() {
$(this).load($(this).attr("data-href") + " .historyByLine", function() {
$(this).children(".historyByLine").last().remove();
});
});
});
//#JSCOVERAGE_ENDIF

View File

@ -24,6 +24,10 @@
<h1 class="documentFirstHeading" i18n:translate="heading_moderate_comments">
Moderate comments
</h1>
<p>
<a tal:attributes="href string:${context/@@plone_portal_state/navigation_root_url}/comments-approved;">&gt; <span
i18n:translate="heading_comments_approved">Comments approved</span></a>
</p>
<div class="portalMessage warning"
role="status"
@ -114,7 +118,7 @@
</a>
</tal:email>
</td>
<td tal:content="python:toLocalizedTime(item.ModificationDate, long_format=1)"/>
<td tal:content="python:toLocalizedTime(item.created, long_format=1)"/>
<td>
<a tal:attributes="href item/getURL"
tal:content="item/in_response_to" />

View File

@ -52,6 +52,31 @@ class View(BrowserView):
return False
class ApprovedView(View):
"""Overview comments already approved."""
template = ViewPageTemplateFile('comments_approved.pt')
try:
template.id = '@@comments-approved'
except AttributeError:
# id is not writeable in Zope 2.12
pass
def __call__(self):
self.request.set('disable_border', True)
context = aq_inner(self.context)
catalog = getToolByName(context, 'portal_catalog')
self.comments = catalog(object_provides=IComment.__identifier__,
review_state='published',
sort_on='created',
sort_order='reverse')
# print("*** approved comments")
# print(self.comments)
# for el in self.comments:
# print(el.id, el.review_state)
return self.template()
class ModerateCommentsEnabled(BrowserView):
def __call__(self):

View File

@ -134,7 +134,7 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable,
return self.id
def getText(self, targetMimetype=None):
# The body text of a comment.
"""The body text of a comment."""
transforms = getToolByName(self, 'portal_transforms')
if targetMimetype is None: