diff --git a/app/controllers/avoid_posting_versions_controller.rb b/app/controllers/avoid_posting_versions_controller.rb
index 5a887f57c..c6fddbafc 100644
--- a/app/controllers/avoid_posting_versions_controller.rb
+++ b/app/controllers/avoid_posting_versions_controller.rb
@@ -10,7 +10,7 @@ class AvoidPostingVersionsController < ApplicationController
def search_params
permitted_params = %i[updater_name updater_id any_name_matches artist_name artist_id any_other_name_matches group_name is_active]
- permitted_params += %i[updater_ip_addr] if CurrentUser.is_admin?
+ permitted_params += %i[ip_addr] if CurrentUser.is_admin?
permit_search_params permitted_params
end
end
diff --git a/app/controllers/avoid_postings_controller.rb b/app/controllers/avoid_postings_controller.rb
index 65c3fd8f1..9606c3d6f 100644
--- a/app/controllers/avoid_postings_controller.rb
+++ b/app/controllers/avoid_postings_controller.rb
@@ -27,7 +27,7 @@ class AvoidPostingsController < ApplicationController
def create
@avoid_posting = AvoidPosting.new(avoid_posting_params)
artparams = avoid_posting_params.try(:[], :artist_attributes)
- if artparams.present? && (artist = Artist.find_by(name: Artist.normalize_name(artparams[:name])))
+ if artparams.present? && (artist = Artist.named(artparams[:name]))
@avoid_posting.artist = artist
notices = []
if artist.other_names.present? && (artparams.key?(:other_names_string) || artparams.key?(:other_names))
@@ -69,17 +69,17 @@ class AvoidPostingsController < ApplicationController
def destroy
@avoid_posting.destroy
- redirect_to artist_path(@avoid_posting.artist), notice: "Avoid posting entry destroyed"
+ redirect_to(artist_path(@avoid_posting.artist), notice: "Avoid posting entry destroyed")
end
def delete
@avoid_posting.update(is_active: false)
- redirect_to avoid_posting_path(@avoid_posting), notice: "Avoid posting entry deleted"
+ redirect_back(fallback_location: avoid_posting_path(@avoid_posting), notice: "Avoid posting entry deleted")
end
def undelete
@avoid_posting.update(is_active: true)
- redirect_to avoid_posting_path(@avoid_posting), notice: "Avoid posting entry undeleted"
+ redirect_back(fallback_location: avoid_posting_path(@avoid_posting), notice: "Avoid posting entry undeleted")
end
private
@@ -89,14 +89,14 @@ class AvoidPostingsController < ApplicationController
if id =~ /\A\d+\z/
@avoid_posting = AvoidPosting.find(id)
else
- @avoid_posting = AvoidPosting.find_by!(artist_name: id)
+ @avoid_posting = AvoidPosting.joins(:artist).find_by!("artists.name": id)
end
end
def search_params
permitted_params = %i[creator_name creator_id any_name_matches artist_id artist_name any_other_name_matches group_name details is_active]
permitted_params += %i[staff_notes] if CurrentUser.is_staff?
- permitted_params += %i[creator_ip_addr] if CurrentUser.is_admin?
+ permitted_params += %i[ip_addr] if CurrentUser.is_admin?
permit_search_params permitted_params
end
diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb
index 1290c18d1..6028ac8e1 100644
--- a/app/controllers/static_controller.rb
+++ b/app/controllers/static_controller.rb
@@ -72,7 +72,7 @@ class StaticController < ApplicationController
private
def format_wiki_page(name)
- wiki = WikiPage.find_by(title: name)
+ wiki = WikiPage.titled(name)
return WikiPage.new(body: "Wiki page \"#{name}\" not found.") if wiki.blank?
wiki
end
diff --git a/app/javascript/src/styles/specific/posts.scss b/app/javascript/src/styles/specific/posts.scss
index 96afaca5e..5df49f5d9 100644
--- a/app/javascript/src/styles/specific/posts.scss
+++ b/app/javascript/src/styles/specific/posts.scss
@@ -336,10 +336,6 @@ div#c-posts {
background-color: themed("color-section");
border: 1px solid themed("color-foreground");
- /*.artist-separator {
- color: var(--color-text-muted);
- }*/
-
ul {
list-style: disc;
}
diff --git a/app/models/avoid_posting.rb b/app/models/avoid_posting.rb
index 410759a5a..9ab257f68 100644
--- a/app/models/avoid_posting.rb
+++ b/app/models/avoid_posting.rb
@@ -76,10 +76,6 @@ class AvoidPosting < ApplicationRecord
end
module SearchMethods
- def for_artist(name)
- active.find_by(artist_name: name)
- end
-
def artist_search(params)
Artist.search(params.slice(:any_name_matches, :any_other_name_matches).merge({ id: params[:artist_id], name: params[:artist_name] }))
end
@@ -99,7 +95,7 @@ class AvoidPosting < ApplicationRecord
q = q.attribute_matches(:details, params[:details])
q = q.attribute_matches(:staff_notes, params[:staff_notes])
q = q.where_user(:creator_id, :creator, params)
- q = q.where("creator_ip_addr <<= ?", params[:creator_ip_addr]) if params[:creator_ip_addr].present?
+ q = q.where("creator_ip_addr <<= ?", params[:ip_addr]) if params[:ip_addr].present?
q.apply_basic_order(params)
end
end
diff --git a/app/models/avoid_posting_version.rb b/app/models/avoid_posting_version.rb
index 613e4aee0..4a352813d 100644
--- a/app/models/avoid_posting_version.rb
+++ b/app/models/avoid_posting_version.rb
@@ -15,7 +15,7 @@ class AvoidPostingVersion < ApplicationRecord
end
def previous
- AvoidPostingVersion.joins(:avoid_posting).where(id: ...id).order(id: :desc).first
+ AvoidPostingVersion.joins(:avoid_posting).where("avoid_posting_versions.id < ?", id).order(id: :desc).first
end
module ApiMethods
@@ -38,7 +38,7 @@ class AvoidPostingVersion < ApplicationRecord
q = q.attribute_matches(:is_active, params[:is_active])
q = q.where_user(:updater_id, :updater, params)
- q = q.where("updater_ip_addr <<= ?", params[:updater_ip_addr]) if params[:updater_ip_addr].present?
+ q = q.where("updater_ip_addr <<= ?", params[:ip_addr]) if params[:ip_addr].present?
q.apply_basic_order(params)
end
end
diff --git a/app/views/artists/_form.html.erb b/app/views/artists/_form.html.erb
index acedfd1e9..11a79b068 100644
--- a/app/views/artists/_form.html.erb
+++ b/app/views/artists/_form.html.erb
@@ -7,7 +7,7 @@
<% else %>
<%= @artist.name %>
<% if @artist.dnp_restricted? %>
- Name, other names, and group name cannot be edited for artists on the <%= link_to "Avoid Posting", avoid_postings_path %> list.
+ Name, other names, and group name cannot be edited for artists on the <%= link_to "Avoid Posting", avoid_posting_static_path %> list.
<% end %>
<% end %>
<% if CurrentUser.is_janitor? %>
diff --git a/app/views/artists/_secondary_links.html.erb b/app/views/artists/_secondary_links.html.erb
index 1875300c4..3b2894b27 100644
--- a/app/views/artists/_secondary_links.html.erb
+++ b/app/views/artists/_secondary_links.html.erb
@@ -1,7 +1,7 @@
<% content_for(:secondary_links) do %>
<%= render "artists/quick_search" %>
<%= subnav_link_to "Listing", artists_path %>
- <%= subnav_link_to "Avoid Posting", avoid_postings_path %>
+ <%= subnav_link_to "Avoid Posting", avoid_posting_static_path %>
<% if CurrentUser.is_member? %>
<%= subnav_link_to "New", new_artist_path %>
<% end %>
diff --git a/app/views/artists/_show.html.erb b/app/views/artists/_show.html.erb
index 529babc85..20dea752c 100644
--- a/app/views/artists/_show.html.erb
+++ b/app/views/artists/_show.html.erb
@@ -9,7 +9,7 @@
<% if @artist.is_dnp? %>
-
This artist is on the <%= link_to "Avoid Posting", avoid_postings_path %> list.
+
This artist is on the <%= link_to "Avoid Posting", avoid_posting_static_path %> list.
<% if @artist.avoid_posting.pretty_details.present? %>
<%= format_text(@artist.avoid_posting.pretty_details, inline: true) %>
diff --git a/app/views/avoid_posting_versions/_search.html.erb b/app/views/avoid_posting_versions/_search.html.erb
index f032caf74..65a810004 100644
--- a/app/views/avoid_posting_versions/_search.html.erb
+++ b/app/views/avoid_posting_versions/_search.html.erb
@@ -1,7 +1,7 @@
<%= form_search(path: avoid_posting_versions_path) do |f| %>
<%= f.user :updater %>
<% if CurrentUser.is_admin? %>
- <%= f.input :updater_ip_addr, label: "Updater IP Address" %>
+ <%= f.input :ip_addr, label: "Updater IP Address" %>
<% end %>
<%= f.input :any_name_matches, label: "Name", hint: "Use * for wildcard", autocomplete: "artist" %>
<%= f.input :artist_name, label: "Artist Name", hide_unless_value: true %>
diff --git a/app/views/avoid_postings/_search.html.erb b/app/views/avoid_postings/_search.html.erb
index adcbe1228..dfdc77efb 100644
--- a/app/views/avoid_postings/_search.html.erb
+++ b/app/views/avoid_postings/_search.html.erb
@@ -1,7 +1,7 @@
<%= form_search(path: avoid_postings_path, always_display: true) do |f| %>
<%= f.user :creator %>
<% if CurrentUser.is_admin? %>
- <%= f.input :creator_ip_addr, label: "Creator IP Address" %>
+ <%= f.input :ip_addr, label: "Creator IP Address" %>
<% end %>
<%= f.input :any_name_matches, label: "Name", hint: "Use * for wildcard", autocomplete: "artist" %>
<%= f.input :artist_name, label: "Artist Name", hide_unless_value: true %>
diff --git a/app/views/avoid_postings/edit.html.erb b/app/views/avoid_postings/edit.html.erb
index d8d0c56fb..160a2bc42 100644
--- a/app/views/avoid_postings/edit.html.erb
+++ b/app/views/avoid_postings/edit.html.erb
@@ -1,6 +1,6 @@
-
Edit Avoid Posting for <%= link_to @avoid_posting.artist_name, avoid_posting_path(@avoid_posting), class: "tag-type-1" %>
+
Edit Avoid Posting for <%= link_to @avoid_posting.artist_name, avoid_posting_path(@avoid_posting), class: "tag-type-#{Tag.categories.artist}" %>
<%= error_messages_for :avoid_posting %>
<%= render "form" %>
diff --git a/app/views/avoid_postings/index.html.erb b/app/views/avoid_postings/index.html.erb
index 98f8897d2..8366bd769 100644
--- a/app/views/avoid_postings/index.html.erb
+++ b/app/views/avoid_postings/index.html.erb
@@ -52,7 +52,11 @@
<%= link_to "Show", avoid_posting_path(avoid_posting) %>
<% if CurrentUser.can_edit_avoid_posting_entries? %>
| <%= link_to "Edit", edit_avoid_posting_path(avoid_posting) %>
- | <%= link_to "Delete", delete_avoid_posting_path(avoid_posting), method: :put, data: { confirm: "Are you sure you want to delete this avoid posting?" } %>
+ <% if avoid_posting.is_active? %>
+ | <%= link_to "Delete", delete_avoid_posting_path(avoid_posting), method: :put, data: { confirm: "Are you sure you want to delete this avoid posting entry?" } %>
+ <% else %>
+ | <%= link_to "Undelete", undelete_avoid_posting_path(avoid_posting), method: :put, data: { confirm: "Are you sure you want to undelete this avoid posting entry?" } %>
+ <% end %>
<% end %>
diff --git a/app/views/avoid_postings/show.html.erb b/app/views/avoid_postings/show.html.erb
index 6a237a0ac..e7242710a 100644
--- a/app/views/avoid_postings/show.html.erb
+++ b/app/views/avoid_postings/show.html.erb
@@ -1,6 +1,6 @@
-
Avoid Posting: <%= link_to @avoid_posting.artist_name, show_or_new_artists_path(name: @avoid_posting.artist_name), class: "tag-type-1" %><%= " (inactive)" unless @avoid_posting.is_active? %>
+
Avoid Posting: <%= link_to @avoid_posting.artist_name, show_or_new_artists_path(name: @avoid_posting.artist_name), class: "tag-type-#{Tag.categories.artist}" %><%= " (inactive)" unless @avoid_posting.is_active? %>
- Status <%= @avoid_posting.status %>
diff --git a/app/views/static/site_map.html.erb b/app/views/static/site_map.html.erb
index eda0277b8..f0c654c46 100644
--- a/app/views/static/site_map.html.erb
+++ b/app/views/static/site_map.html.erb
@@ -37,7 +37,8 @@
Artists
- <%= link_to("Listing", artists_path) %>
- - <%= link_to("Avoid Posting", avoid_postings_path) %>
+ - <%= link_to("Avoid Posting Entries", avoid_postings_path) %>
+ - <%= link_to("Avoid Posting List", avoid_posting_static_path) %>
- <%= link_to("Changes", artist_versions_path) %>
- <%= link_to("Help", help_page_path(id: "artists")) %>
diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb
index 9d30b5683..9de88c5e9 100644
--- a/config/danbooru_default_config.rb
+++ b/config/danbooru_default_config.rb
@@ -460,7 +460,7 @@ module Danbooru
},
{
name: "dnp_artist",
- reason: "The artist of this post is on the \"avoid posting list\":/avoid_postings",
+ reason: "The artist of this post is on the \"avoid posting list\":/static/avoid_posting",
text: "Certain artists have requested that their work is not to be published on this site, and were granted [[avoid_posting|Do Not Post]] status.\nSometimes, that status comes with conditions; see [[conditional_dnp]] for more information",
},
{
@@ -527,7 +527,7 @@ module Danbooru
"Traced artwork",
"Traced artwork (post #%PARENT_ID%)",
"Takedown #%OTHER_ID%",
- "The artist of this post is on the \"avoid posting list\":/avoid_postings",
+ "The artist of this post is on the \"avoid posting list\":/static/avoid_posting",
"[[conditional_dnp|Conditional DNP]] (Only the artist is allowed to post)",
"[[conditional_dnp|Conditional DNP]] (%OTHER_ID%)",
]
diff --git a/test/controllers/avoid_postings_controller_test.rb b/test/controllers/avoid_postings_controller_test.rb
index 4f6ae78e2..124729d1c 100644
--- a/test/controllers/avoid_postings_controller_test.rb
+++ b/test/controllers/avoid_postings_controller_test.rb
@@ -27,6 +27,11 @@ class AvoidPostingsControllerTest < ActionDispatch::IntegrationTest
get_auth avoid_posting_path(@avoid_posting), @user
assert_response :success
end
+
+ should "render (by name)" do
+ get_auth avoid_posting_path(id: @avoid_posting.artist_name), @user
+ assert_response :success
+ end
end
context "edit action" do
diff --git a/test/factories/avoid_posting.rb b/test/factories/avoid_posting.rb
index 435127956..d02463010 100644
--- a/test/factories/avoid_posting.rb
+++ b/test/factories/avoid_posting.rb
@@ -3,7 +3,6 @@
FactoryBot.define do
factory(:avoid_posting) do
association :artist
- is_active { true }
association :creator, factory: :bd_staff_user
creator_ip_addr { "127.0.0.1" }
end