moved artist ban to separate action/button
This commit is contained in:
@@ -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|
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" %>
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
<li><%= link_to "Show", 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>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<%= link_to "Ban", ban_artist_path(@artist), :method => :put %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</menu>
|
||||
<% end %>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user