diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 3ae607380..4ab9a897c 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,8 +1,8 @@ class ArtistsController < ApplicationController respond_to :html, :xml, :json 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 :builder_only, :only => [:edit_name, :update_name] def new @artist = Artist.new_with_defaults(params) @@ -82,6 +82,24 @@ class ArtistsController < ApplicationController respond_with(@artist) 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 @artist = Artist.find(params[:id]) @version = ArtistVersion.find(params[:version_id]) diff --git a/app/models/artist.rb b/app/models/artist.rb index 6e0a7b051..a0c07d0dc 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -317,8 +317,10 @@ class Artist < ActiveRecord::Base extend SearchMethods def status - if is_banned? + if is_banned? && is_active? "Banned" + elsif is_banned? + "Banned Deleted" elsif is_active? "Active" else @@ -341,4 +343,8 @@ class Artist < ActiveRecord::Base def initialize_creator self.creator_id = CurrentUser.user.id end + + def deletable_by?(user) + user.is_builder? + end end diff --git a/app/views/artists/_form.html.erb b/app/views/artists/_form.html.erb index 040a7db26..a96ebd89b 100644 --- a/app/views/artists/_form.html.erb +++ b/app/views/artists/_form.html.erb @@ -12,9 +12,6 @@ <%= f.input :other_names_comma, :hint => "Separate with commas", :as => :text, :label => "Other names" %> <%= f.input :group_name %> <%= 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" %> <%= f.button :submit, "Submit" %> diff --git a/app/views/artists/_secondary_links.html.erb b/app/views/artists/_secondary_links.html.erb index 069f9307d..7b4c4ede8 100644 --- a/app/views/artists/_secondary_links.html.erb +++ b/app/views/artists/_secondary_links.html.erb @@ -16,8 +16,15 @@