fixes #1672
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
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 :builder_only, :only => [:edit_name, :update_name, :destroy]
|
||||||
before_filter :admin_only, :only => [:ban]
|
before_filter :admin_only, :only => [:ban]
|
||||||
before_filter :builder_only, :only => [:edit_name, :update_name]
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@artist = Artist.new_with_defaults(params)
|
@artist = Artist.new_with_defaults(params)
|
||||||
@@ -82,6 +82,24 @@ class ArtistsController < ApplicationController
|
|||||||
respond_with(@artist)
|
respond_with(@artist)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@artist = Artist.find(params[:id])
|
||||||
|
if !@artist.deletable_by?(CurrentUser.user)
|
||||||
|
raise User::PrivilegeError
|
||||||
|
end
|
||||||
|
@artist.update_attribute(:is_active, false)
|
||||||
|
respond_with(@artist, :notice => "Artist deleted")
|
||||||
|
end
|
||||||
|
|
||||||
|
def undelete
|
||||||
|
@artist = Artist.find(params[:id])
|
||||||
|
if !@artist.deletable_by?(CurrentUser.user)
|
||||||
|
raise User::PrivilegeError
|
||||||
|
end
|
||||||
|
@artist.update_attribute(:is_active, true)
|
||||||
|
respond_with(@artist, :notice => "Artist undeleted")
|
||||||
|
end
|
||||||
|
|
||||||
def revert
|
def revert
|
||||||
@artist = Artist.find(params[:id])
|
@artist = Artist.find(params[:id])
|
||||||
@version = ArtistVersion.find(params[:version_id])
|
@version = ArtistVersion.find(params[:version_id])
|
||||||
|
|||||||
@@ -317,8 +317,10 @@ class Artist < ActiveRecord::Base
|
|||||||
extend SearchMethods
|
extend SearchMethods
|
||||||
|
|
||||||
def status
|
def status
|
||||||
if is_banned?
|
if is_banned? && is_active?
|
||||||
"Banned"
|
"Banned"
|
||||||
|
elsif is_banned?
|
||||||
|
"Banned Deleted"
|
||||||
elsif is_active?
|
elsif is_active?
|
||||||
"Active"
|
"Active"
|
||||||
else
|
else
|
||||||
@@ -341,4 +343,8 @@ class Artist < ActiveRecord::Base
|
|||||||
def initialize_creator
|
def initialize_creator
|
||||||
self.creator_id = CurrentUser.user.id
|
self.creator_id = CurrentUser.user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deletable_by?(user)
|
||||||
|
user.is_builder?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
<%= f.input :other_names_comma, :hint => "Separate with commas", :as => :text, :label => "Other names" %>
|
<%= f.input :other_names_comma, :hint => "Separate with commas", :as => :text, :label => "Other names" %>
|
||||||
<%= f.input :group_name %>
|
<%= f.input :group_name %>
|
||||||
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %>
|
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %>
|
||||||
<% if CurrentUser.is_builder? %>
|
|
||||||
<%= f.input :is_active %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= dtext_field "artist", "notes" %>
|
<%= dtext_field "artist", "notes" %>
|
||||||
<%= f.button :submit, "Submit" %>
|
<%= f.button :submit, "Submit" %>
|
||||||
|
|||||||
@@ -16,8 +16,15 @@
|
|||||||
<li><%= link_to "Edit name", edit_name_artist_path(@artist) %></li>
|
<li><%= link_to "Edit name", edit_name_artist_path(@artist) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<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 @artist.deletable_by?(CurrentUser.user) %>
|
||||||
|
<% if @artist.is_active? %>
|
||||||
|
<li><%= link_to "Delete", artist_path(@artist), :method => :delete, :confirm => "Are you sure you want to delete this artist?" %></li>
|
||||||
|
<% else %>
|
||||||
|
<li><%= link_to "Undelete", undelete_artist_path(@artist), :method => :post, :confirm => "Are you sure you want to undelete this artist?" %></li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
<% if CurrentUser.is_admin? %>
|
<% if CurrentUser.is_admin? %>
|
||||||
<%= link_to "Ban", ban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to ban this artist?" %>
|
<li><%= link_to "Ban", ban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to ban this artist?" %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ Danbooru::Application.routes.draw do
|
|||||||
put :ban
|
put :ban
|
||||||
get :edit_name
|
get :edit_name
|
||||||
put :update_name
|
put :update_name
|
||||||
|
post :undelete
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get :show_or_new
|
get :show_or_new
|
||||||
|
|||||||
Reference in New Issue
Block a user