diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 98f479934..d9e505e15 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,7 +1,6 @@ class ArtistsController < ApplicationController respond_to :html, :xml, :json, :js before_action :member_only, :except => [:index, :show, :show_or_new, :banned] - before_action :builder_only, :only => [:destroy] before_action :admin_only, :only => [:ban, :unban] before_action :load_artist, :only => [:ban, :unban, :show, :edit, :update, :destroy, :undelete] @@ -61,9 +60,6 @@ class ArtistsController < ApplicationController end def destroy - if !@artist.deletable_by?(CurrentUser.user) - raise User::PrivilegeError - end @artist.update_attribute(:is_active, false) redirect_to(artist_path(@artist), :notice => "Artist deleted") end @@ -96,8 +92,7 @@ private end def artist_params(context = nil) - permitted_params = %i[name other_names other_names_string group_name url_string notes] - permitted_params << :is_active if CurrentUser.is_builder? + permitted_params = %i[name other_names other_names_string group_name url_string notes is_active] permitted_params << :source if context == :new params.fetch(:artist, {}).permit(permitted_params) diff --git a/app/models/artist.rb b/app/models/artist.rb index 096eb2db0..a48001257 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -538,14 +538,6 @@ class Artist < ApplicationRecord end end - def deletable_by?(user) - user.is_builder? - end - - def editable_by?(user) - user.is_builder? || (!is_banned? && is_active?) - end - def visible? !is_banned? || CurrentUser.is_gold? end diff --git a/app/views/artists/_form.html.erb b/app/views/artists/_form.html.erb index ca8904038..39d4956c2 100644 --- a/app/views/artists/_form.html.erb +++ b/app/views/artists/_form.html.erb @@ -1,10 +1,8 @@ <%= simple_form_for(@artist) do |f| %> <% if @artist.new_record? %> <%= f.input :name, as: :string, input_html: { data: { autocomplete: "tag" } } %> - <% elsif CurrentUser.user.is_builder? %> - <%= f.input :name, as: :string, input_html: { data: { autocomplete: "tag" } }, hint: "Change to rename this artist entry and its wiki page" %> <% else %> -

<%= @artist.name %>

+ <%= f.input :name, as: :string, input_html: { data: { autocomplete: "tag" } }, hint: "Change to rename this artist entry and its wiki page" %> <% end %> <%= f.input :other_names_string, label: "Other names", as: :text, input_html: { size: "50x1" }, hint: 'NEW Separate names with spaces, not commas. Use underscores for spaces inside names.'.html_safe %> diff --git a/app/views/artists/_secondary_links.html.erb b/app/views/artists/_secondary_links.html.erb index 1882447d0..37aaf4726 100644 --- a/app/views/artists/_secondary_links.html.erb +++ b/app/views/artists/_secondary_links.html.erb @@ -15,7 +15,7 @@ <%= subnav_link_to "Edit", edit_artist_path(@artist), :"data-shortcut" => "e" %> <% end %> <%= subnav_link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %> - <% if @artist.deletable_by?(CurrentUser.user) %> + <% if CurrentUser.is_member? %> <% if @artist.is_active? %> <%= subnav_link_to "Delete", artist_path(@artist), method: :delete, "data-shortcut": "shift+d", "data-confirm": "Are you sure you want to delete this artist?" %> <% else %> @@ -25,7 +25,6 @@ <% if CurrentUser.is_admin? %> <% if @artist.is_banned? %> <%= subnav_link_to "Unban", unban_artist_path(@artist), :method => :put, :data => {:confirm => "Are you sure you want to unban this artist?"} %> - <% else %> <%= subnav_link_to "Ban", ban_artist_path(@artist), :method => :put, :data => {:confirm => "Are you sure you want to ban this artist?"} %> <% end %> diff --git a/app/views/artists/edit.html.erb b/app/views/artists/edit.html.erb index 1c22ca9e2..763cb077e 100644 --- a/app/views/artists/edit.html.erb +++ b/app/views/artists/edit.html.erb @@ -2,15 +2,10 @@

Edit Artist

- <% if @artist.editable_by?(CurrentUser.user) %> - <%= render "form" %> - - <% elsif !@artist.is_active? %> -

This artist entry is inactive and cannot be edited.

- - <% elsif @artist.is_banned? %> + <% if @artist.is_banned? %>

The artist requested removal of this page.

- + <% else %> + <%= render "form" %> <% end %>
diff --git a/app/views/artists/index.html.erb b/app/views/artists/index.html.erb index 60141ac94..0f4fc69ed 100644 --- a/app/views/artists/index.html.erb +++ b/app/views/artists/index.html.erb @@ -40,14 +40,14 @@ <%= time_ago_in_words_tagged(artist.updated_at) %> - <% if artist.editable_by?(CurrentUser.user) %> + <% if CurrentUser.is_member? %> <%= link_to "Edit", edit_artist_path(artist) %> - <% end %> - <% if artist.is_active? && artist.deletable_by?(CurrentUser.user) %> - | <%= link_to "Delete", artist_path(artist, artist: { is_active: false }), method: :put, remote: true %> - <% elsif !artist.is_active? && artist.deletable_by?(CurrentUser.user) %> - | <%= link_to "Undelete", artist_path(artist, artist: { is_active: true }), method: :put, remote: true %> + <% if artist.is_active? %> + | <%= link_to "Delete", artist_path(artist, artist: { is_active: false }), method: :put, remote: true %> + <% else %> + | <%= link_to "Undelete", artist_path(artist, artist: { is_active: true }), method: :put, remote: true %> + <% end %> <% end %> <% end %>