/post_{flags,appeals}: allow searching by tags.
This commit is contained in:
@@ -16,6 +16,10 @@ class PostAppeal < ActiveRecord::Base
|
|||||||
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
|
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def post_tags_match(query)
|
||||||
|
PostQueryBuilder.new(query).build(self.joins(:post))
|
||||||
|
end
|
||||||
|
|
||||||
def resolved
|
def resolved
|
||||||
joins(:post).where("posts.is_deleted = false and posts.is_flagged = false")
|
joins(:post).where("posts.is_deleted = false and posts.is_flagged = false")
|
||||||
end
|
end
|
||||||
@@ -56,6 +60,10 @@ class PostAppeal < ActiveRecord::Base
|
|||||||
q = q.where("post_id = ?", params[:post_id].to_i)
|
q = q.where("post_id = ?", params[:post_id].to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:post_tags_match].present?
|
||||||
|
q = q.post_tags_match(params[:post_tags_match])
|
||||||
|
end
|
||||||
|
|
||||||
if params[:is_resolved] == "true"
|
if params[:is_resolved] == "true"
|
||||||
q = q.resolved
|
q = q.resolved
|
||||||
elsif params[:is_resolved] == "false"
|
elsif params[:is_resolved] == "false"
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ class PostFlag < ActiveRecord::Base
|
|||||||
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
|
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def post_tags_match(query)
|
||||||
|
PostQueryBuilder.new(query).build(self.joins(:post))
|
||||||
|
end
|
||||||
|
|
||||||
def resolved
|
def resolved
|
||||||
where("is_resolved = ?", true)
|
where("is_resolved = ?", true)
|
||||||
end
|
end
|
||||||
@@ -64,6 +68,10 @@ class PostFlag < ActiveRecord::Base
|
|||||||
q = q.where("post_id = ?", params[:post_id].to_i)
|
q = q.where("post_id = ?", params[:post_id].to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:post_tags_match].present?
|
||||||
|
q = q.post_tags_match(params[:post_tags_match])
|
||||||
|
end
|
||||||
|
|
||||||
if params[:is_resolved] == "true"
|
if params[:is_resolved] == "true"
|
||||||
q = q.resolved
|
q = q.resolved
|
||||||
elsif params[:is_resolved] == "false"
|
elsif params[:is_resolved] == "false"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<%= simple_form_for(:search, url: post_appeals_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
<%= simple_form_for(:search, url: post_appeals_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||||
<%= f.input :reason_matches, label: "Reason", input_html: { value: params[:search][:reason_matches] } %>
|
<%= f.input :reason_matches, label: "Reason", input_html: { value: params[:search][:reason_matches] } %>
|
||||||
|
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match] } %>
|
||||||
<%= f.input :post_id, label: "Post ID", input_html: { value: params[:search][:post_id] } %>
|
<%= f.input :post_id, label: "Post ID", input_html: { value: params[:search][:post_id] } %>
|
||||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
||||||
<%= f.input :is_resolved, label: "Resolved?", collection: [["Yes", true], ["No", false]], selected: params[:search][:is_resolved] %>
|
<%= f.input :is_resolved, label: "Resolved?", collection: [["Yes", true], ["No", false]], selected: params[:search][:is_resolved] %>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<%= simple_form_for(:search, url: post_flags_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
<%= simple_form_for(:search, url: post_flags_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||||
<%= f.input :reason_matches, label: "Reason", input_html: { value: params[:search][:reason_matches] } %>
|
<%= f.input :reason_matches, label: "Reason", input_html: { value: params[:search][:reason_matches] } %>
|
||||||
|
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match] } %>
|
||||||
<%= f.input :post_id, label: "Post ID", input_html: { value: params[:search][:post_id] } %>
|
<%= f.input :post_id, label: "Post ID", input_html: { value: params[:search][:post_id] } %>
|
||||||
<% if CurrentUser.is_moderator? %>
|
<% if CurrentUser.is_moderator? %>
|
||||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
||||||
|
|||||||
Reference in New Issue
Block a user