post_flags/index: remove banned and duplicate search options.
Remove options for searching for "Artist requested removal" and "duplicate" flag reasons. These were legacy flag reasons that haven't been used for a long time.
This commit is contained in:
@@ -4,7 +4,6 @@ class PostFlag < ApplicationRecord
|
|||||||
module Reasons
|
module Reasons
|
||||||
UNAPPROVED = "Unapproved in three days"
|
UNAPPROVED = "Unapproved in three days"
|
||||||
REJECTED = "Unapproved in three days after returning to moderation queue%"
|
REJECTED = "Unapproved in three days after returning to moderation queue%"
|
||||||
BANNED = "Artist requested removal"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
COOLDOWN_PERIOD = 3.days
|
COOLDOWN_PERIOD = 3.days
|
||||||
@@ -27,14 +26,6 @@ class PostFlag < ApplicationRecord
|
|||||||
scope :old, -> { where("post_flags.created_at <= ?", 3.days.ago) }
|
scope :old, -> { where("post_flags.created_at <= ?", 3.days.ago) }
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def duplicate
|
|
||||||
where("to_tsvector('english', post_flags.reason) @@ to_tsquery('dup | duplicate | sample | smaller')")
|
|
||||||
end
|
|
||||||
|
|
||||||
def not_duplicate
|
|
||||||
where("to_tsvector('english', post_flags.reason) @@ to_tsquery('!dup & !duplicate & !sample & !smaller')")
|
|
||||||
end
|
|
||||||
|
|
||||||
def search(params)
|
def search(params)
|
||||||
q = super
|
q = super
|
||||||
|
|
||||||
@@ -64,17 +55,13 @@ class PostFlag < ApplicationRecord
|
|||||||
|
|
||||||
case params[:category]
|
case params[:category]
|
||||||
when "normal"
|
when "normal"
|
||||||
q = q.where("reason NOT IN (?) AND reason NOT LIKE ?", [Reasons::UNAPPROVED, Reasons::BANNED], Reasons::REJECTED)
|
q = q.where("reason NOT IN (?) AND reason NOT LIKE ?", [Reasons::UNAPPROVED], Reasons::REJECTED)
|
||||||
when "unapproved"
|
when "unapproved"
|
||||||
q = q.where(reason: Reasons::UNAPPROVED)
|
q = q.where(reason: Reasons::UNAPPROVED)
|
||||||
when "banned"
|
|
||||||
q = q.where(reason: Reasons::BANNED)
|
|
||||||
when "rejected"
|
when "rejected"
|
||||||
q = q.where("reason LIKE ?", Reasons::REJECTED)
|
q = q.where("reason LIKE ?", Reasons::REJECTED)
|
||||||
when "deleted"
|
when "deleted"
|
||||||
q = q.where("reason = ? OR reason LIKE ?", Reasons::UNAPPROVED, Reasons::REJECTED)
|
q = q.where("reason = ? OR reason LIKE ?", Reasons::UNAPPROVED, Reasons::REJECTED)
|
||||||
when "duplicate"
|
|
||||||
q = q.duplicate
|
|
||||||
end
|
end
|
||||||
|
|
||||||
q.apply_default_order(params)
|
q.apply_default_order(params)
|
||||||
@@ -98,8 +85,6 @@ class PostFlag < ApplicationRecord
|
|||||||
:unapproved
|
:unapproved
|
||||||
when /#{Reasons::REJECTED.gsub("%", ".*")}/
|
when /#{Reasons::REJECTED.gsub("%", ".*")}/
|
||||||
:rejected
|
:rejected
|
||||||
when Reasons::BANNED
|
|
||||||
:banned
|
|
||||||
else
|
else
|
||||||
:normal
|
:normal
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,6 +6,6 @@
|
|||||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %>
|
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name], data: { autocomplete: "user" } } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= f.input :is_resolved, label: "Resolved?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:is_resolved] %>
|
<%= f.input :is_resolved, label: "Resolved?", collection: [["Yes", true], ["No", false]], include_blank: true, selected: params[:search][:is_resolved] %>
|
||||||
<%= f.input :category, label: "Category", collection: ["normal", "unapproved", "rejected", "deleted", "banned", "duplicate"], include_blank: true, selected: params[:search][:category] %>
|
<%= f.input :category, label: "Category", collection: ["normal", "unapproved", "rejected", "deleted"], include_blank: true, selected: params[:search][:category] %>
|
||||||
<%= f.submit "Search" %>
|
<%= f.submit "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user