From b8f14b6fee31852ab8e9849fb22d294c468f6a43 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Wed, 27 Jan 2016 17:02:03 -0800 Subject: [PATCH] hide more pages for banned artists #2132 --- app/controllers/artists_controller.rb | 15 ++-- app/models/artist_version.rb | 1 + app/models/wiki_page_version.rb | 1 + app/views/artist_versions/index.html.erb | 24 ++++--- app/views/artists/edit.html.erb | 7 +- app/views/artists/show.html.erb | 59 ++++++++------- .../posts/partials/index/_excerpt.html.erb | 72 ++++++++++--------- .../posts/partials/show/_notices.html.erb | 2 +- app/views/static/access_denied.html.erb | 2 + app/views/wiki_page_versions/diff.html.erb | 12 ++-- app/views/wiki_page_versions/show.html.erb | 2 +- app/views/wiki_pages/edit.html.erb | 7 +- 12 files changed, 117 insertions(+), 87 deletions(-) diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index fb5f839a3..75f0a58d0 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -3,6 +3,7 @@ class ArtistsController < ApplicationController before_filter :member_only, :except => [:index, :show, :banned] before_filter :builder_only, :only => [:destroy] before_filter :admin_only, :only => [:ban, :unban] + before_filter :load_artist, :only => [:ban, :unban, :show, :edit, :update, :destroy, :undelete, :revert] def new @artist = Artist.new_with_defaults(params) @@ -10,7 +11,6 @@ class ArtistsController < ApplicationController end def edit - @artist = Artist.find(params[:id]) respond_with(@artist) end @@ -27,13 +27,11 @@ class ArtistsController < ApplicationController end def ban - @artist = Artist.find(params[:id]) @artist.ban! redirect_to(artist_path(@artist), :notice => "Artist was banned") end def unban - @artist = Artist.find(params[:id]) @artist.unban! redirect_to(artist_path(@artist), :notice => "Artist was unbanned") end @@ -73,7 +71,6 @@ class ArtistsController < ApplicationController end def update - @artist = Artist.find(params[:id]) body = params[:artist].delete("notes") @artist.assign_attributes(params[:artist], :as => CurrentUser.role) if body @@ -84,7 +81,6 @@ class ArtistsController < ApplicationController end def destroy - @artist = Artist.find(params[:id]) if !@artist.deletable_by?(CurrentUser.user) raise User::PrivilegeError end @@ -93,7 +89,6 @@ class ArtistsController < ApplicationController end def undelete - @artist = Artist.find(params[:id]) if !@artist.deletable_by?(CurrentUser.user) raise User::PrivilegeError end @@ -102,7 +97,6 @@ class ArtistsController < ApplicationController end def revert - @artist = Artist.find(params[:id]) @version = ArtistVersion.find(params[:version_id]) @artist.revert_to!(@version) respond_with(@artist) @@ -131,4 +125,11 @@ class ArtistsController < ApplicationController end end end + +private + + def load_artist + @artist = Artist.find(params[:id]) + end + end diff --git a/app/models/artist_version.rb b/app/models/artist_version.rb index 2047bd5e3..b7f73c2ca 100644 --- a/app/models/artist_version.rb +++ b/app/models/artist_version.rb @@ -2,6 +2,7 @@ class ArtistVersion < ActiveRecord::Base belongs_to :updater, :class_name => "User" belongs_to :artist attr_accessible :artist_id, :name, :is_active, :other_names, :group_name, :url_string, :is_banned, :updater_id, :updater_ip_addr + delegate :visible?, :to => :artist module SearchMethods def for_user(user_id) diff --git a/app/models/wiki_page_version.rb b/app/models/wiki_page_version.rb index 14d35f9f8..962d13a7f 100644 --- a/app/models/wiki_page_version.rb +++ b/app/models/wiki_page_version.rb @@ -3,6 +3,7 @@ class WikiPageVersion < ActiveRecord::Base belongs_to :updater, :class_name => "User" belongs_to :artist attr_accessible :wiki_page_id, :title, :body, :is_locked, :updater_id, :updater_ip_addr, :version, :other_names + delegate :visible?, :to => :wiki_page module SearchMethods def for_user(user_id) diff --git a/app/views/artist_versions/index.html.erb b/app/views/artist_versions/index.html.erb index 4ff60209c..9420d127b 100644 --- a/app/views/artist_versions/index.html.erb +++ b/app/views/artist_versions/index.html.erb @@ -24,11 +24,15 @@ <% @artist_versions.each do |artist_version| %> - - <%= link_to artist_version.name, artist_path(artist_version.artist_id) %> - - <%= artist_version_other_names_diff(artist_version) %> - <%= artist_version.group_name %> + <% if artist_version.visible? %> + <%= link_to artist_version.name, artist_path(artist_version.artist_id) %> + <%= artist_version_other_names_diff(artist_version) %> + <%= artist_version.group_name %> + <% else %> + + + + <% end %> <%= compact_time artist_version.created_at %> <%= link_to_user artist_version.updater %> <% if CurrentUser.is_moderator? %> @@ -37,11 +41,11 @@ <% end %> <%= artist_version.is_active? %> - - - + <% if artist_version.visible? %> + + <% else %> + + <% end %> <% if CurrentUser.is_member? %> <%= link_to "Revert to", revert_artist_path(artist_version.artist_id, :version_id => artist_version.id), :method => :put, :data => {:confirm => "Are you sure you want to revert to this version?"} %> diff --git a/app/views/artists/edit.html.erb b/app/views/artists/edit.html.erb index b17f420fc..97cfcc3e8 100644 --- a/app/views/artists/edit.html.erb +++ b/app/views/artists/edit.html.erb @@ -1,7 +1,12 @@

Edit Artist

- <%= render "form" %> + + <% if @artist.visible? %> + <%= render "form" %> + <% else %> +

The artist requested removal of this page.

+ <% end %>
diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index ec90c9f8c..17447bba0 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -2,7 +2,7 @@

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

- <% if @artist.notes.present? && (!@artist.is_banned? || CurrentUser.user.is_member?) %> + <% if @artist.notes.present? && @artist.visible? %>
<%= format_text(@artist.notes) %>
@@ -10,34 +10,39 @@

<%= link_to "View wiki page", @artist.wiki_page %>

<% end %> -
-
    -
  • Status <%= @artist.status %>
  • + <% if @artist.visible? %> +
    +
      +
    • Status <%= @artist.status %>
    • - <% if !@artist.is_banned? || CurrentUser.user.is_member? %> - <% if @artist.has_tag_alias? %> -
    • Tag Alias <%= @artist.tag_alias_name %>
    • + <% if !@artist.is_banned? || CurrentUser.user.is_member? %> + <% if @artist.has_tag_alias? %> +
    • Tag Alias <%= @artist.tag_alias_name %>
    • + <% end %> + <% if @artist.other_names.present? %> +
    • Other Names <%= link_to_artists(@artist.other_names.split(/ /)) %>
    • + <% end %> + <% if @artist.group_name.present? %> +
    • Group <%= link_to_artist(@artist.group_name) %>
    • + <% end %> + <% if @artist.members.any? %> +
    • Members <%= link_to_artists(@artist.members.map(&:name)) %>
    • + <% end %> + <% @artist.urls.each do |url| %> +
    • + URL: <%= link_to h(url.to_s), h(url.to_s) %> + <% if CurrentUser.user.is_moderator? %> + (<%= link_to("mass edit", edit_moderator_tag_path(:antecedent => "-#{@artist.name} source:#{ArtistUrl.normalize_for_search(url.to_s)}", :consequent => @artist.name)) %>) + <% end %> +
    • + <% end %> <% end %> - <% if @artist.other_names.present? %> -
    • Other Names <%= link_to_artists(@artist.other_names.split(/ /)) %>
    • - <% end %> - <% if @artist.group_name.present? %> -
    • Group <%= link_to_artist(@artist.group_name) %>
    • - <% end %> - <% if @artist.members.any? %> -
    • Members <%= link_to_artists(@artist.members.map(&:name)) %>
    • - <% end %> - <% @artist.urls.each do |url| %> -
    • - URL: <%= link_to h(url.to_s), h(url.to_s) %> - <% if CurrentUser.user.is_moderator? %> - (<%= link_to("mass edit", edit_moderator_tag_path(:antecedent => "-#{@artist.name} source:#{ArtistUrl.normalize_for_search(url.to_s)}", :consequent => @artist.name)) %>) - <% end %> -
    • - <% end %> - <% end %> -
    -
    +
+
+ + <% else %> +

The artist requested removal of this page.

+ <% end %> <%= render "secondary_links" %>
diff --git a/app/views/posts/partials/index/_excerpt.html.erb b/app/views/posts/partials/index/_excerpt.html.erb index f0724f0e1..6ef74599c 100644 --- a/app/views/posts/partials/index/_excerpt.html.erb +++ b/app/views/posts/partials/index/_excerpt.html.erb @@ -4,43 +4,45 @@