add moderate-comments view.

svn path=/plone.app.discussion/trunk/; revision=27369
This commit is contained in:
Timo Stollenwerk 2009-06-10 20:14:44 +00:00
parent c1696a9756
commit 1e71258a0d
4 changed files with 190 additions and 0 deletions

View File

@ -8,6 +8,15 @@
<!-- Traversal adapter --> <!-- Traversal adapter -->
<adapter factory=".traversal.ConversationNamespace" name="conversation" /> <adapter factory=".traversal.ConversationNamespace" name="conversation" />
<!-- Moderation view -->
<browser:page
for="Products.CMFCore.interfaces.ISiteRoot"
name="moderate-comments"
layer="..interfaces.IDiscussionLayer"
class=".moderation.View"
permission="cmf.ManagePortal"
/>
<!-- Comments viewlet --> <!-- Comments viewlet -->
<browser:viewlet <browser:viewlet
name="plone.comments" name="plone.comments"

View File

@ -0,0 +1,125 @@
<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="collective.discussionplus">
<body>
<metal:scripts fill-slot="javascript_head_slot">
<script type="text/javascript">
(function($) {$().ready(function() {
$('form.background-form').submit(function(e) {
e.preventDefault();
var target = $(this).attr('action');
var params = $(this).serialize();
var cell = $(this).parent().get(0);
var row = $(cell).parent().get(0);
$.post(target, params, function(data) {
$(row).fadeOut("normal", function() {
$(this).remove();
if($('#review-comments tbody tr').length == 0) {
$('#comments-help').fadeOut();
$('#review-comments').fadeOut("normal", function() {
$('#no-comments-message').fadeIn();
});
}
});
});
});
});})(jQuery);
</script>
</metal:scripts>
<metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main"
tal:define="items view/comments_pending_review">
<h1 class="documentFirstHeading" i18n:translate="title_review">
Review comments
</h1>
<p id="no-comments-message" i18n:translate="message_nothing_to_review"
tal:attributes="style python:len(items) > 0 and 'display: none' or None">
No comments to review. To look for more comments,
<a i18n:name="refresh-link" i18n:translate="message_click_to_refresh"
tal:attributes="href context/@@plone_context_state/current_page_url">
click here to refresh.
</a>
</p>
<p id="comments-help" tal:condition="items" class="discreet" i18n:translate="description_review">
Comments for review are listed below. For each one, click
<em>Delete</em> to remove the comment or <em>Publish</em> to
publish it. Note that at most <span i18n:name="limit" tal:content="view/limit" />
comments will be shown at a time. If there are further comments,
you will be able to see them once you have published or deleted
the first batch.
</p>
<table id="review-comments" class="listing nosort" style="width: 100%" tal:condition="items">
<thead>
<tr>
<th i18n:translate="heading_author">Author</th>
<th i18n:translate="heading_date">Date</th>
<th i18n:translate="heading_context">Context</th>
<th i18n:translate="heading_subject">Subject</th>
<th i18n:translate="heading_comment">Comment</th>
<th i18n:translate="heading_action">Action</th>
</tr>
</thead>
<tbody>
<tal:block repeat="item items">
<tr style="vertical-align: top" class="commentrow">
<td tal:content="item/Creator" />
<td tal:content="python:view.format_time(item.ModificationDate)" />
<td>
<!--<a tal:attributes="href item/getURL"
tal:content="item/comment_subject" />-->
</td>
<td>
<a tal:attributes="href item/getURL"
tal:content="item/Title" />
</td>
<td tal:content="structure python:view.cook(item.Description)" />
<td style="width: 11em">
<form action=""
class="background-form"
method="post"
style="display: inline"
tal:attributes="action string:${item/getURL}/@@review-publish-comment">
<input type="hidden" name="comment_id" tal:attributes="value item/getId" />
<input type="hidden" name="action" tal:attributes="value view/transition" />
<input class="context comment-publish-button"
type="submit"
value="Publish"
i18n:attributes="value label_publish"
/>
</form>
<form action=""
method="post"
class="background-form"
style="display: inline"
tal:attributes="action string:${item/getURL}/@@review-delete-comment">
<input type="hidden" name="comment_id" tal:attributes="value item/getId" />
<input class="destructive comment-delete-button"
type="submit"
value="Delete"
i18n:attributes="value label_delete;"
/>
</form>
</td>
</tr>
</tal:block>
</tbody>
</table>
</tal:main-macro>
</metal:main>
</body>
</html>

View File

@ -0,0 +1,40 @@
from Acquisition import aq_inner, aq_parent
from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.CMFCore.utils import getToolByName
class View(BrowserView):
"""
"""
template = ViewPageTemplateFile('moderation.pt')
def __call__(self):
return self.template()
def cook(self, text):
return ""
def format_time(self, time):
context = aq_inner(self.context)
util = getToolByName(context, 'translation_service')
return util.ulocalized_time(time, 1, context, domain='plonelocales')
def comments_pending_review(self):
self.state = self.request.get('review_state', 'pending')
self.transition = self.request.get('publish_transition', 'pending')
self.limit = self.request.get('limit', 100)
context = aq_inner(self.context)
catalog = getToolByName(context, 'portal_catalog')
return catalog(
path='/'.join(context.getPhysicalPath()),
portal_type='Discussion Item',
review_state=self.state,
sort_on='created',
sort_limit=self.limit,
)

View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<object name="portal_actions" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<object name="site_actions">
<object name="review-comments" meta_type="CMF Action" i18n:domain="plone.app.discussion">
<property name="title" i18n:translate="">Moderate comments</property>
<property name="description" i18n:translate=""></property>
<property name="url_expr">string:$portal_url/@@moderate-comments</property>
<property name="icon_expr"></property>
<property name="available_expr"></property>
<property name="permissions">
<element value="Review comments"/>
</property>
<property name="visible">True</property>
</object>
</object>
</object>