filter tabs removed from moderation view;

svn path=/plone.app.discussion/trunk/; revision=32355
This commit is contained in:
Timo Stollenwerk 2009-12-08 11:19:26 +00:00
parent 094f5955a4
commit 47cba8797f
5 changed files with 20 additions and 158 deletions

View File

@ -55,23 +55,15 @@ jq(document).ready(function() {
var form = jq(row).parents("form"); var form = jq(row).parents("form");
var path = jq(row).find("input:checkbox").attr("value"); var path = jq(row).find("input:checkbox").attr("value");
var target = path + "/@@moderate-publish-comment"; var target = path + "/@@moderate-publish-comment";
var currentFilter = jq(form).find("[name='form.button.Filter']").attr("value");
jq.ajax({ jq.ajax({
type: "GET", type: "GET",
url: target, url: target,
data: "workflow_action=publish", data: "workflow_action=publish",
success: function(msg){ success: function(msg){
if (currentFilter == 'pending') { // fade out row
// fade out row jq(row).fadeOut("normal", function(){
jq(row).fadeOut("normal", function(){ jq(this).remove();
jq(this).remove(); });
});
} else {
// fade out button
jq(button).fadeOut("normal", function(){
jq(this).remove();
});
}
}, },
error: function(msg){ error: function(msg){
alert("Error sending AJAX request:" + target); alert("Error sending AJAX request:" + target);
@ -89,34 +81,15 @@ jq(document).ready(function() {
var target = jq(form).attr('action'); var target = jq(form).attr('action');
var params = jq(form).serialize(); var params = jq(form).serialize();
var valArray = jq('input:checkbox:checked'); var valArray = jq('input:checkbox:checked');
var currentFilter = jq(form).find("[name='form.button.Filter']").attr("value");
var currentAction = jq(form).find("[name='form.select.BulkAction']").val();
var selectField = jq(form).find("[name='form.select.BulkAction']"); var selectField = jq(form).find("[name='form.select.BulkAction']");
if (valArray.length) { if (valArray.length) {
jq.post(target, params, function(data) { jq.post(target, params, function(data) {
valArray.each(function () { valArray.each(function () {
// if bulkaction is delete, or the current filter is /* Remove all selected lines. */
// pending (because then publish also removes the comment), var row = jq(this).parent().parent();
// remove all selected comments. row.fadeOut("normal", function() {
if (currentAction == 'delete' || currentFilter == 'pending') { row.remove();
var row = jq(this).parent().parent(); });
row.fadeOut("normal", function() {
row.remove();
});
}
// bulkaction is publish and there is no current filter
if (currentAction == 'publish' && currentFilter == '') {
// remove the publish button
var row = jq(this).parent().parent();
var form = row.find("form.workflow_action");
var publishButton = row.find(".comment-publish-button");
var selectField = row.find("input:checkbox");
jq(publishButton).fadeOut("normal", function(){
jq(form).remove();
});
// reset the select fields
selectField.attr("checked","");
}
}); });
}); });
} else { } else {

View File

@ -22,38 +22,6 @@
Moderate comments Moderate comments
</h1> </h1>
<ul class="filter formTabs">
<li class="all formTab firstFormTab">
<form method="post"
action="#"
tal:attributes="action string:${context/absolute_url}/@@moderate-comments">
<input type="submit" value="All" class=""
tal:attributes="class python: not filter and 'selected' or ''" />
</form>
</li>
<li class="pending formTab">
<form method="post" action="#" tal:attributes="action string:${context/absolute_url}/@@moderate-comments">
<input type="hidden" name="form.button.Filter" value="pending" />
<input type="submit" value="Pending" class=""
tal:attributes="class python:filter == 'pending' and 'selected' or ''"/>
</form>
</li>
<li class="approved formTab lastFormTab">
<form method="post" action="#" tal:attributes="action string:${context/absolute_url}/@@moderate-comments">
<input type="hidden" name="form.button.Filter" value="published" />
<input type="submit" value="Published" class=""
tal:attributes="class python:filter == 'published' and 'selected' or ''"/>
</form>
</li>
<!--
<li class="spam">
<a href="#"
tal:attributes="href string:${context/absolute_url}/@@comments-spam"
i18n:translate="title_filter_spam">Spam</a>
</li>
-->
</ul>
<form tal:condition="not:items"> <form tal:condition="not:items">
<fieldset id="fieldset-moderate-comments" class="formPanel"> <fieldset id="fieldset-moderate-comments" class="formPanel">
<p id="no-comments-message" i18n:translate="message_nothing_to_moderate"> <p id="no-comments-message" i18n:translate="message_nothing_to_moderate">
@ -78,11 +46,9 @@
<th id="bulkactions" class="nosort" colspan="7"> <th id="bulkactions" class="nosort" colspan="7">
<select name="form.select.BulkAction"> <select name="form.select.BulkAction">
<option selected="selected" value="-1" i18n:translate="title_bulkactions">Bulk Actions</option> <option selected="selected" value="-1" i18n:translate="title_bulkactions">Bulk Actions</option>
<!--<option value="retract" i18n:translate="bulkactions_retract">Retract</option>-->
<option value="publish" <option value="publish"
i18n:translate="bulkactions_publish" i18n:translate="bulkactions_publish"
tal:condition="python: filter != 'published' and moderation_enabled">Publish</option> tal:condition="python: filter != 'published' and moderation_enabled">Publish</option>
<!--<option value="mark_as_spam" i18n:translate="bulkactions_markasspam">Mark as Spam</option>-->
<option value="delete" i18n:translate="bulkactions_delete">Delete</option> <option value="delete" i18n:translate="bulkactions_delete">Delete</option>
</select> </select>
<input type="hidden" name="form.button.Filter" tal:attributes="value filter" value="" /> <input type="hidden" name="form.button.Filter" tal:attributes="value filter" value="" />

View File

@ -26,16 +26,12 @@ class View(BrowserView):
context = aq_inner(self.context) context = aq_inner(self.context)
if self.request.has_key('form.button.Filter'): catalog = getToolByName(context, 'portal_catalog')
self.filter = self.request.get('form.button.Filter')
if self.filter == 'pending': self.comments = catalog(portal_type='Discussion Item',
self.comments = self.comments_pending() review_state='pending',
elif self.filter == "published": sort_on='created',
self.comments = self.comments_published() sort_order='reverse')
else:
raise ValueError('Value %s for filter is not know.' % self.filter)
else:
self.comments = self.comments_all()
return self.template() return self.template()
def cook(self, text): def cook(self, text):
@ -53,63 +49,6 @@ class View(BrowserView):
else: else:
return False return False
def comments_all(self, start=0, size=None):
"""Returns all comments.
"""
self.state = self.request.get('review_state', 'pending')
self.transition = self.request.get('publish_transition', 'publish')
self.limit = self.request.get('limit', 100)
context = aq_inner(self.context)
catalog = getToolByName(context, 'portal_catalog')
return catalog(
portal_type='Discussion Item',
sort_on='created',
sort_order='reverse',
)
def comments_pending(self, start=0, size=None):
"""Returns all comments with 'pending' review state.
"""
self.state = self.request.get('review_state', 'pending')
self.transition = self.request.get('publish_transition', 'publish')
self.limit = self.request.get('limit', 100)
context = aq_inner(self.context)
catalog = getToolByName(context, 'portal_catalog')
return catalog(
portal_type='Discussion Item',
review_state=self.state,
sort_on='created',
sort_order='reverse',
)
def comments_published(self, start=0, size=None):
"""Returns all comments with 'published' review state.
"""
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(
portal_type='Discussion Item',
review_state='published',
sort_on='created',
sort_order='reverse',
)
def comments_spam(self, start=0, size=None):
"""Returns all comments that are marked as spam.
Not implemented yet.
"""
return None
class DeleteComment(BrowserView): class DeleteComment(BrowserView):
"""Delete a comment from a conversation """Delete a comment from a conversation

View File

@ -144,6 +144,10 @@ ul.filter {
/* These styles are only applied for Plone 4, since Plone 3.x does /* These styles are only applied for Plone 4, since Plone 3.x does
not have a .row class for portal-column-content. */ not have a .row class for portal-column-content. */
.row #dobulkaction {
margin: 0;
}
.row #commenting { .row #commenting {
font-size: 80%; font-size: 80%;
} }

View File

@ -77,26 +77,6 @@ class ModerationViewTest(PloneTestCase):
('simple_publication_workflow,')) ('simple_publication_workflow,'))
self.assertEquals(self.view.moderation_enabled(), False) self.assertEquals(self.view.moderation_enabled(), False)
def test_comments_all(self):
self.failUnless(self.view.comments_all())
self.assertEquals(len(self.view.comments_all()), 3)
def test_comments_pending(self):
self.wf_tool.getInfoFor(self.comment1, 'review_state')
self.failUnless(self.view.comments_pending())
self.assertEquals(len(self.view.comments_pending()), 3)
self.portal.portal_workflow.doActionFor(self.comment1,
action='publish')
#self.comment1.reindexObject()
#self.assertEquals(len(self.view.comments_pending()), 2)
def test_comments_published(self):
self.assertEquals(len(self.view.comments_published()), 0)
self.wf_tool.doActionFor(self.comment1, action='publish')
#self.assertEquals(len(self.view.comments_published()), 1)
def test_comments_spam(self):
self.view.comments_spam()
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)