Skip to content

Commit

Permalink
Add shortcut to disable comments on an article from the comment moder…
Browse files Browse the repository at this point in the history
…ation page.

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2439 567b1171-46fb-0310-a4c9-b4bef9110e78
  • Loading branch information
technoweenie committed Nov 7, 2006
1 parent 69b97bd commit 7b4af24
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,5 +1,7 @@
* SVN *

* Add shortcut to disable comments on an article from the comment moderation page.

* 0.7.1 PRE-RELEASE *

* add more robust tagging [Moritz Angermann]
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/admin/comments_controller.rb
Expand Up @@ -2,4 +2,13 @@ class Admin::CommentsController < Admin::BaseController
def index
@comments = site.unapproved_comments.find(:all, :include => :article)
end

# ajax action, called from _page_nav
def close
@article = site.articles.find(params[:id])
@article.update_attribute :comment_age, -1
render :update do |page|
page.flash.notice "Comments have been closed for this article"
end
end
end
5 changes: 4 additions & 1 deletion app/views/admin/articles/_page_nav.rhtml
Expand Up @@ -4,7 +4,10 @@
<ul id="act-nav" class="clear">
<% if admin? || @article.user_id == current_user.id -%>
<li><%= link_to_remote 'Delete this article', :url => {:action => 'destroy', :id => @article}, :confirm => 'Are you sure you want to delete this article?' %></li>
<li><%= link_to 'Close comments for this article', '' %></li>
<% unless @article.comment_age == -1 -%>
<li id="close-article-comments"><%= link_to_remote 'Close comments for this article',
:url => { :controller => 'admin/comments', :action => 'close', :id => @article } %></li>
<% end -%>
<% end -%>
<% if controller.action_name == 'edit' -%>
<li><%= link_to('Preview', {:action => 'show', :id => @article}, {:target => '_blank'}) %></li>
Expand Down
9 changes: 6 additions & 3 deletions test/functional/admin/comments_controller_test.rb
Expand Up @@ -5,14 +5,17 @@
class Admin::CommentsController; def rescue_action(e) raise e end; end

class Admin::CommentsControllerTest < Test::Unit::TestCase
fixtures :contents, :users, :sites, :memberships
def setup
@controller = Admin::CommentsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
login_as :ben
end

# Replace this with your real tests.
def test_truth
assert true
def test_should_disable_comments_on_article
post :close, :id => contents(:welcome).id
assert_equal -1, contents(:welcome).reload.comment_age
assert_response :success
end
end

0 comments on commit 7b4af24

Please sign in to comment.