From 6bc5b96d8ef226f29da0a9d128f093b47e0be6c7 Mon Sep 17 00:00:00 2001 From: albert Date: Sat, 23 Feb 2013 10:56:27 -0500 Subject: [PATCH] moved artist ban to separate action/button --- app/controllers/artists_controller.rb | 7 +++++++ app/models/artist.rb | 9 --------- app/views/artists/_form.html.erb | 4 ---- app/views/artists/_secondary_links.html.erb | 3 +++ config/routes.rb | 1 + 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index d690fbf12..c66e3ea71 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,6 +1,7 @@ class ArtistsController < ApplicationController respond_to :html, :xml, :json before_filter :member_only, :except => [:index, :show, :banned] + before_filter :admin_only, :only => [:ban] def new @artist = Artist.new_with_defaults(params) @@ -17,6 +18,12 @@ class ArtistsController < ApplicationController respond_with(@artists) end + def ban + @artist = Artist.find(params[:id]) + @artist.ban! + redirect_to(artist_path(@artist), :notice => "Artist was banned") + end + def index @artists = Artist.search(params[:search]).order("id desc").paginate(params[:page]) respond_with(@artists) do |format| diff --git a/app/models/artist.rb b/app/models/artist.rb index 82020c563..55d15a8e1 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -3,7 +3,6 @@ class Artist < ActiveRecord::Base before_save :normalize_name after_save :create_version after_save :save_url_string - after_save :commit_ban validates_uniqueness_of :name belongs_to :creator, :class_name => "User" has_many :members, :class_name => "Artist", :foreign_key => "group_name", :primary_key => "name" @@ -162,14 +161,6 @@ class Artist < ActiveRecord::Base end module BanMethods - def commit_ban - if is_banned? && is_banned_changed? - ban! - end - - true - end - def ban! Post.transaction do begin diff --git a/app/views/artists/_form.html.erb b/app/views/artists/_form.html.erb index caec2f855..f8c6a81c2 100644 --- a/app/views/artists/_form.html.erb +++ b/app/views/artists/_form.html.erb @@ -5,10 +5,6 @@ <%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %> <%= f.input :is_active %> - <% if CurrentUser.is_admin? %> - <%= f.input :is_banned %> - <% end %> - <%= dtext_field "artist", "notes" %> <%= f.button :submit, "Submit" %> <%= dtext_preview_button "artist", "notes" %> diff --git a/app/views/artists/_secondary_links.html.erb b/app/views/artists/_secondary_links.html.erb index 909b892de..271a78e45 100644 --- a/app/views/artists/_secondary_links.html.erb +++ b/app/views/artists/_secondary_links.html.erb @@ -11,6 +11,9 @@
  • <%= link_to "Show", artist_path(@artist) %>
  • <%= link_to "Edit", edit_artist_path(@artist) %>
  • <%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %>
  • + <% if CurrentUser.is_admin? %> + <%= link_to "Ban", ban_artist_path(@artist), :method => :put %> + <% end %> <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 6d8c3c53d..4a51ccb9d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -52,6 +52,7 @@ Danbooru::Application.routes.draw do resources :artists do member do put :revert + put :ban end collection do get :show_or_new