public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
Add shortcut to disable comments on an article from the comment moderation 
page.

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2439 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Mon Nov 06 22:40:38 -0800 2006
commit  7b4af24ee27a683b41df93ed504d0b0db558057e
tree    b872b4d9e8a4b31d7fb52364ee855b5291d6b86b
parent  69b97bdf2333b5dffa013377966806eb99a9ef9f
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 * SVN *
0
 
0
+* Add shortcut to disable comments on an article from the comment moderation page.
0
+
0
 * 0.7.1 PRE-RELEASE *
0
 
0
 * add more robust tagging [Moritz Angermann]
...
2
3
4
 
 
 
 
 
 
 
 
 
5
...
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -2,4 +2,13 @@ class Admin::CommentsController < Admin::BaseController
0
   def index
0
     @comments = site.unapproved_comments.find(:all, :include => :article)
0
   end
0
+
0
+ # ajax action, called from _page_nav
0
+ def close
0
+ @article = site.articles.find(params[:id])
0
+ @article.update_attribute :comment_age, -1
0
+ render :update do |page|
0
+ page.flash.notice "Comments have been closed for this article"
0
+ end
0
+ end
0
 end
...
4
5
6
7
 
 
 
 
8
9
10
...
4
5
6
 
7
8
9
10
11
12
13
0
@@ -4,7 +4,10 @@
0
   <ul id="act-nav" class="clear">
0
   <% if admin? || @article.user_id == current_user.id -%>
0
     <li><%= link_to_remote 'Delete this article', :url => {:action => 'destroy', :id => @article}, :confirm => 'Are you sure you want to delete this article?' %></li>
0
- <li><%= link_to 'Close comments for this article', '' %></li>
0
+ <% unless @article.comment_age == -1 -%>
0
+ <li id="close-article-comments"><%= link_to_remote 'Close comments for this article',
0
+ :url => { :controller => 'admin/comments', :action => 'close', :id => @article } %></li>
0
+ <% end -%>
0
   <% end -%>
0
   <% if controller.action_name == 'edit' -%>
0
     <li><%= link_to('Preview', {:action => 'show', :id => @article}, {:target => '_blank'}) %></li>
...
5
6
7
 
8
9
10
11
 
12
13
14
15
16
 
 
 
 
17
18
...
5
6
7
8
9
10
11
12
13
14
15
 
 
 
16
17
18
19
20
21
0
@@ -5,14 +5,17 @@ require 'admin/comments_controller'
0
 class Admin::CommentsController; def rescue_action(e) raise e end; end
0
 
0
 class Admin::CommentsControllerTest < Test::Unit::TestCase
0
+ fixtures :contents, :users, :sites, :memberships
0
   def setup
0
     @controller = Admin::CommentsController.new
0
     @request = ActionController::TestRequest.new
0
     @response = ActionController::TestResponse.new
0
+ login_as :ben
0
   end
0
 
0
- # Replace this with your real tests.
0
- def test_truth
0
- assert true
0
+ def test_should_disable_comments_on_article
0
+ post :close, :id => contents(:welcome).id
0
+ assert_equal -1, contents(:welcome).reload.comment_age
0
+ assert_response :success
0
   end
0
 end

Comments

    No one has commented yet.