artists: allow members to rename, delete, and undelete artists.

Also allow Members to edit deleted or banned artists. Previously this
was limited in the html, but not in the backend.
This commit is contained in:
evazion
2019-12-16 19:38:16 -06:00
parent ddf928515c
commit fff4e3badd
6 changed files with 12 additions and 33 deletions

View File

@@ -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 %>
<p><%= @artist.name %></p>
<%= 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: '<b style="color: red;">NEW</b> Separate names with spaces, not commas. Use underscores for spaces inside names.'.html_safe %>

View File

@@ -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 %>

View File

@@ -2,15 +2,10 @@
<div id="a-edit">
<h1>Edit Artist</h1>
<% if @artist.editable_by?(CurrentUser.user) %>
<%= render "form" %>
<% elsif !@artist.is_active? %>
<p>This artist entry is inactive and cannot be edited.</p>
<% elsif @artist.is_banned? %>
<% if @artist.is_banned? %>
<p>The artist requested removal of this page.</p>
<% else %>
<%= render "form" %>
<% end %>
</div>
</div>

View File

@@ -40,14 +40,14 @@
<%= time_ago_in_words_tagged(artist.updated_at) %>
</td>
<td>
<% 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 %>
</td>
<% end %>