forked from e621ng/e621ng
[AvoidPosting] Bug fixes and cleanup (#706)
This commit is contained in:
parent
d0559a2ba9
commit
237f79eabe
@ -10,7 +10,7 @@ class AvoidPostingVersionsController < ApplicationController
|
|||||||
|
|
||||||
def search_params
|
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_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
|
permit_search_params permitted_params
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -27,7 +27,7 @@ class AvoidPostingsController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@avoid_posting = AvoidPosting.new(avoid_posting_params)
|
@avoid_posting = AvoidPosting.new(avoid_posting_params)
|
||||||
artparams = avoid_posting_params.try(:[], :artist_attributes)
|
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
|
@avoid_posting.artist = artist
|
||||||
notices = []
|
notices = []
|
||||||
if artist.other_names.present? && (artparams.key?(:other_names_string) || artparams.key?(:other_names))
|
if artist.other_names.present? && (artparams.key?(:other_names_string) || artparams.key?(:other_names))
|
||||||
@ -69,17 +69,17 @@ class AvoidPostingsController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@avoid_posting.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
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
@avoid_posting.update(is_active: false)
|
@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
|
end
|
||||||
|
|
||||||
def undelete
|
def undelete
|
||||||
@avoid_posting.update(is_active: true)
|
@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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -89,14 +89,14 @@ class AvoidPostingsController < ApplicationController
|
|||||||
if id =~ /\A\d+\z/
|
if id =~ /\A\d+\z/
|
||||||
@avoid_posting = AvoidPosting.find(id)
|
@avoid_posting = AvoidPosting.find(id)
|
||||||
else
|
else
|
||||||
@avoid_posting = AvoidPosting.find_by!(artist_name: id)
|
@avoid_posting = AvoidPosting.joins(:artist).find_by!("artists.name": id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_params
|
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[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[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
|
permit_search_params permitted_params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class StaticController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def format_wiki_page(name)
|
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?
|
return WikiPage.new(body: "Wiki page \"#{name}\" not found.") if wiki.blank?
|
||||||
wiki
|
wiki
|
||||||
end
|
end
|
||||||
|
@ -336,10 +336,6 @@ div#c-posts {
|
|||||||
background-color: themed("color-section");
|
background-color: themed("color-section");
|
||||||
border: 1px solid themed("color-foreground");
|
border: 1px solid themed("color-foreground");
|
||||||
|
|
||||||
/*.artist-separator {
|
|
||||||
color: var(--color-text-muted);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
list-style: disc;
|
list-style: disc;
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,6 @@ class AvoidPosting < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def for_artist(name)
|
|
||||||
active.find_by(artist_name: name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def artist_search(params)
|
def artist_search(params)
|
||||||
Artist.search(params.slice(:any_name_matches, :any_other_name_matches).merge({ id: params[:artist_id], name: params[:artist_name] }))
|
Artist.search(params.slice(:any_name_matches, :any_other_name_matches).merge({ id: params[:artist_id], name: params[:artist_name] }))
|
||||||
end
|
end
|
||||||
@ -99,7 +95,7 @@ class AvoidPosting < ApplicationRecord
|
|||||||
q = q.attribute_matches(:details, params[:details])
|
q = q.attribute_matches(:details, params[:details])
|
||||||
q = q.attribute_matches(:staff_notes, params[:staff_notes])
|
q = q.attribute_matches(:staff_notes, params[:staff_notes])
|
||||||
q = q.where_user(:creator_id, :creator, params)
|
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)
|
q.apply_basic_order(params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,7 @@ class AvoidPostingVersion < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def previous
|
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
|
end
|
||||||
|
|
||||||
module ApiMethods
|
module ApiMethods
|
||||||
@ -38,7 +38,7 @@ class AvoidPostingVersion < ApplicationRecord
|
|||||||
|
|
||||||
q = q.attribute_matches(:is_active, params[:is_active])
|
q = q.attribute_matches(:is_active, params[:is_active])
|
||||||
q = q.where_user(:updater_id, :updater, params)
|
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)
|
q.apply_basic_order(params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<p><%= @artist.name %></p>
|
<p><%= @artist.name %></p>
|
||||||
<% if @artist.dnp_restricted? %>
|
<% if @artist.dnp_restricted? %>
|
||||||
<p>Name, other names, and group name cannot be edited for artists on the <%= link_to "Avoid Posting", avoid_postings_path %> list.</p>
|
<p>Name, other names, and group name cannot be edited for artists on the <%= link_to "Avoid Posting", avoid_posting_static_path %> list.</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if CurrentUser.is_janitor? %>
|
<% if CurrentUser.is_janitor? %>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<% content_for(:secondary_links) do %>
|
<% content_for(:secondary_links) do %>
|
||||||
<li><%= render "artists/quick_search" %></li>
|
<li><%= render "artists/quick_search" %></li>
|
||||||
<%= subnav_link_to "Listing", artists_path %>
|
<%= 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? %>
|
<% if CurrentUser.is_member? %>
|
||||||
<%= subnav_link_to "New", new_artist_path %>
|
<%= subnav_link_to "New", new_artist_path %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<% if @artist.is_dnp? %>
|
<% if @artist.is_dnp? %>
|
||||||
<div id="avoid-posting">
|
<div id="avoid-posting">
|
||||||
<h2>This artist is on the <%= link_to "Avoid Posting", avoid_postings_path %> list.</h2>
|
<h2>This artist is on the <%= link_to "Avoid Posting", avoid_posting_static_path %> list.</h2>
|
||||||
<% if @artist.avoid_posting.pretty_details.present? %>
|
<% if @artist.avoid_posting.pretty_details.present? %>
|
||||||
<div class="dtext-container">
|
<div class="dtext-container">
|
||||||
<%= format_text(@artist.avoid_posting.pretty_details, inline: true) %>
|
<%= format_text(@artist.avoid_posting.pretty_details, inline: true) %>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<%= form_search(path: avoid_posting_versions_path) do |f| %>
|
<%= form_search(path: avoid_posting_versions_path) do |f| %>
|
||||||
<%= f.user :updater %>
|
<%= f.user :updater %>
|
||||||
<% if CurrentUser.is_admin? %>
|
<% if CurrentUser.is_admin? %>
|
||||||
<%= f.input :updater_ip_addr, label: "Updater IP Address" %>
|
<%= f.input :ip_addr, label: "Updater IP Address" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= f.input :any_name_matches, label: "Name", hint: "Use * for wildcard", autocomplete: "artist" %>
|
<%= f.input :any_name_matches, label: "Name", hint: "Use * for wildcard", autocomplete: "artist" %>
|
||||||
<%= f.input :artist_name, label: "Artist Name", hide_unless_value: true %>
|
<%= f.input :artist_name, label: "Artist Name", hide_unless_value: true %>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<%= form_search(path: avoid_postings_path, always_display: true) do |f| %>
|
<%= form_search(path: avoid_postings_path, always_display: true) do |f| %>
|
||||||
<%= f.user :creator %>
|
<%= f.user :creator %>
|
||||||
<% if CurrentUser.is_admin? %>
|
<% if CurrentUser.is_admin? %>
|
||||||
<%= f.input :creator_ip_addr, label: "Creator IP Address" %>
|
<%= f.input :ip_addr, label: "Creator IP Address" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= f.input :any_name_matches, label: "Name", hint: "Use * for wildcard", autocomplete: "artist" %>
|
<%= f.input :any_name_matches, label: "Name", hint: "Use * for wildcard", autocomplete: "artist" %>
|
||||||
<%= f.input :artist_name, label: "Artist Name", hide_unless_value: true %>
|
<%= f.input :artist_name, label: "Artist Name", hide_unless_value: true %>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div class="c-avoid-postings">
|
<div class="c-avoid-postings">
|
||||||
<div class="a-edit">
|
<div class="a-edit">
|
||||||
<h1>Edit Avoid Posting for <%= link_to @avoid_posting.artist_name, avoid_posting_path(@avoid_posting), class: "tag-type-1" %></h1>
|
<h1>Edit Avoid Posting for <%= link_to @avoid_posting.artist_name, avoid_posting_path(@avoid_posting), class: "tag-type-#{Tag.categories.artist}" %></h1>
|
||||||
|
|
||||||
<%= error_messages_for :avoid_posting %>
|
<%= error_messages_for :avoid_posting %>
|
||||||
<%= render "form" %>
|
<%= render "form" %>
|
||||||
|
@ -52,7 +52,11 @@
|
|||||||
<%= link_to "Show", avoid_posting_path(avoid_posting) %>
|
<%= link_to "Show", avoid_posting_path(avoid_posting) %>
|
||||||
<% if CurrentUser.can_edit_avoid_posting_entries? %>
|
<% if CurrentUser.can_edit_avoid_posting_entries? %>
|
||||||
| <%= link_to "Edit", edit_avoid_posting_path(avoid_posting) %>
|
| <%= 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 %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div id="c-avoid-postings">
|
<div id="c-avoid-postings">
|
||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<h1>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? %></h1>
|
<h1>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? %></h1>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>Status</strong> <%= @avoid_posting.status %></li>
|
<li><strong>Status</strong> <%= @avoid_posting.status %></li>
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li><h1>Artists</h1></li>
|
<li><h1>Artists</h1></li>
|
||||||
<li><%= link_to("Listing", artists_path) %></li>
|
<li><%= link_to("Listing", artists_path) %></li>
|
||||||
<li><%= link_to("Avoid Posting", avoid_postings_path) %></li>
|
<li><%= link_to("Avoid Posting Entries", avoid_postings_path) %></li>
|
||||||
|
<li><%= link_to("Avoid Posting List", avoid_posting_static_path) %></li>
|
||||||
<li><%= link_to("Changes", artist_versions_path) %></li>
|
<li><%= link_to("Changes", artist_versions_path) %></li>
|
||||||
<li><%= link_to("Help", help_page_path(id: "artists")) %></li>
|
<li><%= link_to("Help", help_page_path(id: "artists")) %></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -460,7 +460,7 @@ module Danbooru
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "dnp_artist",
|
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",
|
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",
|
||||||
"Traced artwork (post #%PARENT_ID%)",
|
"Traced artwork (post #%PARENT_ID%)",
|
||||||
"Takedown #%OTHER_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]] (Only the artist is allowed to post)",
|
||||||
"[[conditional_dnp|Conditional DNP]] (%OTHER_ID%)",
|
"[[conditional_dnp|Conditional DNP]] (%OTHER_ID%)",
|
||||||
]
|
]
|
||||||
|
@ -27,6 +27,11 @@ class AvoidPostingsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
get_auth avoid_posting_path(@avoid_posting), @user
|
get_auth avoid_posting_path(@avoid_posting), @user
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "render (by name)" do
|
||||||
|
get_auth avoid_posting_path(id: @avoid_posting.artist_name), @user
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "edit action" do
|
context "edit action" do
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory(:avoid_posting) do
|
factory(:avoid_posting) do
|
||||||
association :artist
|
association :artist
|
||||||
is_active { true }
|
|
||||||
association :creator, factory: :bd_staff_user
|
association :creator, factory: :bd_staff_user
|
||||||
creator_ip_addr { "127.0.0.1" }
|
creator_ip_addr { "127.0.0.1" }
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user