moved artist ban to separate action/button
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
class ArtistsController < ApplicationController
|
class ArtistsController < ApplicationController
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
before_filter :member_only, :except => [:index, :show, :banned]
|
before_filter :member_only, :except => [:index, :show, :banned]
|
||||||
|
before_filter :admin_only, :only => [:ban]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@artist = Artist.new_with_defaults(params)
|
@artist = Artist.new_with_defaults(params)
|
||||||
@@ -17,6 +18,12 @@ class ArtistsController < ApplicationController
|
|||||||
respond_with(@artists)
|
respond_with(@artists)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ban
|
||||||
|
@artist = Artist.find(params[:id])
|
||||||
|
@artist.ban!
|
||||||
|
redirect_to(artist_path(@artist), :notice => "Artist was banned")
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@artists = Artist.search(params[:search]).order("id desc").paginate(params[:page])
|
@artists = Artist.search(params[:search]).order("id desc").paginate(params[:page])
|
||||||
respond_with(@artists) do |format|
|
respond_with(@artists) do |format|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ class Artist < ActiveRecord::Base
|
|||||||
before_save :normalize_name
|
before_save :normalize_name
|
||||||
after_save :create_version
|
after_save :create_version
|
||||||
after_save :save_url_string
|
after_save :save_url_string
|
||||||
after_save :commit_ban
|
|
||||||
validates_uniqueness_of :name
|
validates_uniqueness_of :name
|
||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
has_many :members, :class_name => "Artist", :foreign_key => "group_name", :primary_key => "name"
|
has_many :members, :class_name => "Artist", :foreign_key => "group_name", :primary_key => "name"
|
||||||
@@ -162,14 +161,6 @@ class Artist < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
module BanMethods
|
module BanMethods
|
||||||
def commit_ban
|
|
||||||
if is_banned? && is_banned_changed?
|
|
||||||
ban!
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def ban!
|
def ban!
|
||||||
Post.transaction do
|
Post.transaction do
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -5,10 +5,6 @@
|
|||||||
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %>
|
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %>
|
||||||
<%= f.input :is_active %>
|
<%= f.input :is_active %>
|
||||||
|
|
||||||
<% if CurrentUser.is_admin? %>
|
|
||||||
<%= f.input :is_banned %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= dtext_field "artist", "notes" %>
|
<%= dtext_field "artist", "notes" %>
|
||||||
<%= f.button :submit, "Submit" %>
|
<%= f.button :submit, "Submit" %>
|
||||||
<%= dtext_preview_button "artist", "notes" %>
|
<%= dtext_preview_button "artist", "notes" %>
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
<li><%= link_to "Show", artist_path(@artist) %></li>
|
<li><%= link_to "Show", artist_path(@artist) %></li>
|
||||||
<li><%= link_to "Edit", edit_artist_path(@artist) %></li>
|
<li><%= link_to "Edit", edit_artist_path(@artist) %></li>
|
||||||
<li><%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %></li>
|
<li><%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %></li>
|
||||||
|
<% if CurrentUser.is_admin? %>
|
||||||
|
<%= link_to "Ban", ban_artist_path(@artist), :method => :put %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ Danbooru::Application.routes.draw do
|
|||||||
resources :artists do
|
resources :artists do
|
||||||
member do
|
member do
|
||||||
put :revert
|
put :revert
|
||||||
|
put :ban
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get :show_or_new
|
get :show_or_new
|
||||||
|
|||||||
Reference in New Issue
Block a user