filter tabs removed from moderation view;
svn path=/plone.app.discussion/trunk/; revision=32355
This commit is contained in:
		
							parent
							
								
									094f5955a4
								
							
						
					
					
						commit
						47cba8797f
					
				| @ -55,23 +55,15 @@ jq(document).ready(function() { | ||||
|         var form = jq(row).parents("form"); | ||||
|         var path = jq(row).find("input:checkbox").attr("value"); | ||||
|         var target = path + "/@@moderate-publish-comment"; | ||||
|         var currentFilter = jq(form).find("[name='form.button.Filter']").attr("value"); | ||||
|         jq.ajax({ | ||||
|             type: "GET", | ||||
|             url: target, | ||||
| 			data: "workflow_action=publish", | ||||
|             success: function(msg){ | ||||
| 				if (currentFilter == 'pending') { | ||||
|                     // fade out row
 | ||||
|                     jq(row).fadeOut("normal", function(){ | ||||
|                         jq(this).remove(); | ||||
|                     }); | ||||
| 				} else { | ||||
| 					// fade out button
 | ||||
| 					jq(button).fadeOut("normal", function(){ | ||||
| 						jq(this).remove(); | ||||
| 					}); | ||||
| 				} | ||||
|                 // fade out row
 | ||||
|                 jq(row).fadeOut("normal", function(){ | ||||
|                     jq(this).remove(); | ||||
|                 }); | ||||
|             }, | ||||
|             error: function(msg){ | ||||
|                 alert("Error sending AJAX request:" + target); | ||||
| @ -89,34 +81,15 @@ jq(document).ready(function() { | ||||
|         var target = jq(form).attr('action'); | ||||
|         var params = jq(form).serialize(); | ||||
|         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']"); | ||||
|         if (valArray.length) { | ||||
|             jq.post(target, params, function(data) { | ||||
|                 valArray.each(function () { | ||||
|                     // if bulkaction is delete, or the current filter is
 | ||||
|                     // pending (because then publish also removes the comment),
 | ||||
|                     // remove all selected comments.
 | ||||
|                     if (currentAction == 'delete' || currentFilter == 'pending') { | ||||
|                         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",""); | ||||
|                     } | ||||
| 					/* Remove all selected lines. */ | ||||
|                     var row = jq(this).parent().parent(); | ||||
|                     row.fadeOut("normal", function() { | ||||
|                        row.remove(); | ||||
|                     }); | ||||
|                 }); | ||||
|             }); | ||||
|         } else { | ||||
|  | ||||
| @ -22,38 +22,6 @@ | ||||
|             Moderate comments | ||||
|         </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"> | ||||
|             <fieldset id="fieldset-moderate-comments" class="formPanel"> | ||||
|                 <p id="no-comments-message" i18n:translate="message_nothing_to_moderate"> | ||||
| @ -78,11 +46,9 @@ | ||||
|                             <th id="bulkactions" class="nosort" colspan="7"> | ||||
|                                 <select name="form.select.BulkAction"> | ||||
|                                     <option selected="selected" value="-1" i18n:translate="title_bulkactions">Bulk Actions</option> | ||||
|                                     <!--<option value="retract" i18n:translate="bulkactions_retract">Retract</option>--> | ||||
|                                     <option value="publish" | ||||
|                                             i18n:translate="bulkactions_publish" | ||||
|                                             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> | ||||
|                                 </select> | ||||
|                                 <input type="hidden" name="form.button.Filter" tal:attributes="value filter" value="" /> | ||||
|  | ||||
| @ -26,16 +26,12 @@ class View(BrowserView): | ||||
| 
 | ||||
|         context = aq_inner(self.context) | ||||
| 
 | ||||
|         if self.request.has_key('form.button.Filter'): | ||||
|             self.filter = self.request.get('form.button.Filter') | ||||
|             if self.filter == 'pending': | ||||
|                 self.comments = self.comments_pending() | ||||
|             elif self.filter == "published": | ||||
|                 self.comments = self.comments_published() | ||||
|             else: | ||||
|                 raise ValueError('Value %s for filter is not know.' % self.filter) | ||||
|         else: | ||||
|             self.comments = self.comments_all() | ||||
|         catalog = getToolByName(context, 'portal_catalog') | ||||
| 
 | ||||
|         self.comments = catalog(portal_type='Discussion Item', | ||||
|                                 review_state='pending', | ||||
|                                 sort_on='created', | ||||
|                                 sort_order='reverse') | ||||
|         return self.template() | ||||
| 
 | ||||
|     def cook(self, text): | ||||
| @ -53,63 +49,6 @@ class View(BrowserView): | ||||
|         else: | ||||
|             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): | ||||
|     """Delete a comment from a conversation | ||||
|  | ||||
| @ -144,6 +144,10 @@ ul.filter { | ||||
| /* These styles are only applied for Plone 4, since Plone 3.x does  | ||||
|     not have a .row class for portal-column-content. */ | ||||
| 
 | ||||
| .row #dobulkaction { | ||||
| 	margin: 0; | ||||
| } | ||||
| 
 | ||||
| .row #commenting { | ||||
| 	font-size: 80%; | ||||
| } | ||||
|  | ||||
| @ -77,26 +77,6 @@ class ModerationViewTest(PloneTestCase): | ||||
|                                             ('simple_publication_workflow,')) | ||||
|         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(): | ||||
|     return unittest.defaultTestLoader.loadTestsFromName(__name__) | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user