From 6b066f2cab5bd2758ae59fa5e6118ab2dfa80f43 Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 29 Jan 2020 20:11:44 -0600 Subject: [PATCH] Fix #4275: Unable to update "banned artist" entries. Allow all users to view and edit artist entries and wiki pages belonging to banned artists. There was little need to hide these pages from Members, it was mainly to appease artists who didn't like us even linking to their sites. These restrictions also had multiple flaws: * Banned artist information was still visible in the API. * It was still possible to edit banned artists using the API. * It was still possible for unprivileged users to revert banned artist entries or wiki pages to previous versions. * The restrictions were inconsistent: in various places they were either Member-only, Gold-only, or Builder-only. --- app/logical/post_sets/post.rb | 4 +- app/models/artist.rb | 4 -- app/models/artist_version.rb | 1 - app/models/wiki_page.rb | 4 -- app/models/wiki_page_version.rb | 1 - app/views/artist_versions/_listing.html.erb | 22 +++---- app/views/artists/_show.html.erb | 2 +- app/views/artists/_summary.html.erb | 62 +++++++++---------- app/views/artists/edit.html.erb | 6 +- app/views/artists/show.html.erb | 10 +-- .../posts/partials/index/_excerpt.html.erb | 28 ++++----- app/views/wiki_page_versions/diff.html.erb | 14 ++--- app/views/wiki_page_versions/show.html.erb | 12 ++-- app/views/wiki_pages/edit.html.erb | 6 +- app/views/wiki_pages/show.html.erb | 32 +++++----- 15 files changed, 83 insertions(+), 125 deletions(-) diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 88cd0ba36..43230b9b4 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -26,7 +26,7 @@ module PostSets def wiki_page return nil unless tag.present? && tag.wiki_page.present? - return nil unless !tag.wiki_page.is_deleted? && tag.wiki_page.visible? + return nil unless !tag.wiki_page.is_deleted? tag.wiki_page end @@ -37,7 +37,7 @@ module PostSets def artist return nil unless tag.present? && tag.category == Tag.categories.artist - return nil unless tag.artist.present? && tag.artist.is_active? && tag.artist.visible? + return nil unless tag.artist.present? && tag.artist.is_active? tag.artist end diff --git a/app/models/artist.rb b/app/models/artist.rb index b344a4bf4..f85bcc044 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -538,8 +538,4 @@ class Artist < ApplicationRecord "Deleted" end end - - def visible? - !is_banned? || CurrentUser.is_gold? - end end diff --git a/app/models/artist_version.rb b/app/models/artist_version.rb index 03bde80fa..3a75a4168 100644 --- a/app/models/artist_version.rb +++ b/app/models/artist_version.rb @@ -4,7 +4,6 @@ class ArtistVersion < ApplicationRecord belongs_to_updater belongs_to :artist - delegate :visible?, :to => :artist module SearchMethods def search(params) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 18f6a57f6..7df94325b 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -244,10 +244,6 @@ class WikiPage < ApplicationRecord TagAlias.to_aliased(titles & tags) end - def visible? - artist.blank? || !artist.is_banned? || CurrentUser.is_builder? - end - def to_param if title =~ /\A\d+\z/ "~#{title}" diff --git a/app/models/wiki_page_version.rb b/app/models/wiki_page_version.rb index b0da8ffb3..3dbdec763 100644 --- a/app/models/wiki_page_version.rb +++ b/app/models/wiki_page_version.rb @@ -3,7 +3,6 @@ class WikiPageVersion < ApplicationRecord belongs_to :wiki_page belongs_to_updater belongs_to :artist, optional: true - delegate :visible?, :to => :wiki_page module SearchMethods def search(params) diff --git a/app/views/artist_versions/_listing.html.erb b/app/views/artist_versions/_listing.html.erb index a9315b7a0..0275adff0 100644 --- a/app/views/artist_versions/_listing.html.erb +++ b/app/views/artist_versions/_listing.html.erb @@ -2,26 +2,22 @@ <%= table_for @artist_versions, {class: "striped autofit", width: "100%"} do |t| %> <% t.column "Name" do |artist_version| %> - <% if artist_version.visible? %> - <%= link_to artist_version.name, artist_path(artist_version.artist_id) %> - <%= link_to "»", artist_versions_path(search: {artist_id: artist_version.artist_id}) %> + <%= link_to artist_version.name, artist_path(artist_version.artist_id) %> + <%= link_to "»", artist_versions_path(search: {artist_id: artist_version.artist_id}) %> - <% if !artist_version.is_active? %> - (deleted) - <% end %> + <% if !artist_version.is_active? %> + (deleted) + <% end %> - <% if artist_version.group_name.present? %> -

(group: <%= artist_version.group_name %>)

- <% end %> + <% if artist_version.group_name.present? %> +

(group: <%= artist_version.group_name %>)

<% end %> <% end %> <% t.column "Other Names" do |artist_version| %> - <% if artist_version.visible? %> - <%= artist_version_other_names_diff(artist_version) %> - <% end %> + <%= artist_version_other_names_diff(artist_version) %> <% end %> <% t.column "URLs", td: {class: "col-expand"} do |artist_version| %> - <%= artist_version_urls_diff(artist_version) if artist_version.visible? %> + <%= artist_version_urls_diff(artist_version) %> <% end %> <% t.column "Updated" do |artist_version| %> <%= link_to_user artist_version.updater %> diff --git a/app/views/artists/_show.html.erb b/app/views/artists/_show.html.erb index fd1270394..2dc98e1ab 100644 --- a/app/views/artists/_show.html.erb +++ b/app/views/artists/_show.html.erb @@ -5,7 +5,7 @@

Artist: <%= link_to @artist.pretty_name, posts_path(:tags => @artist.name), :class => "tag-type-#{@artist.category_name}" %>

- <% if @artist.notes.present? && @artist.visible? %> + <% if @artist.notes.present? %>
<%= format_text(@artist.notes, :disable_mentions => true) %>
diff --git a/app/views/artists/_summary.html.erb b/app/views/artists/_summary.html.erb index d0c40d008..7c13f0f1c 100644 --- a/app/views/artists/_summary.html.erb +++ b/app/views/artists/_summary.html.erb @@ -2,37 +2,35 @@ diff --git a/app/views/artists/edit.html.erb b/app/views/artists/edit.html.erb index 763cb077e..ed5a45c62 100644 --- a/app/views/artists/edit.html.erb +++ b/app/views/artists/edit.html.erb @@ -2,11 +2,7 @@

Edit Artist

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

The artist requested removal of this page.

- <% else %> - <%= render "form" %> - <% end %> + <%= render "form" %>
diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index f07270296..19b92f942 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -1,9 +1,5 @@ <%= render layout: "show" do %> - <% if @artist.visible? %> -
- <%= render "summary", artist: @artist %> -
- <% else %> -

The artist requested removal of this page.

- <% end %> +
+ <%= render "summary", artist: @artist %> +
<% end %> diff --git a/app/views/posts/partials/index/_excerpt.html.erb b/app/views/posts/partials/index/_excerpt.html.erb index 5773c7b37..2106e2525 100644 --- a/app/views/posts/partials/index/_excerpt.html.erb +++ b/app/views/posts/partials/index/_excerpt.html.erb @@ -3,23 +3,21 @@