/post_{flags,appeals}: allow searching by tags.

This commit is contained in:
evazion
2017-03-03 19:30:12 -06:00
parent f5e22ea235
commit 8d45bb6d52
4 changed files with 18 additions and 0 deletions

View File

@@ -16,6 +16,10 @@ class PostAppeal < ActiveRecord::Base
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
end
def post_tags_match(query)
PostQueryBuilder.new(query).build(self.joins(:post))
end
def resolved
joins(:post).where("posts.is_deleted = false and posts.is_flagged = false")
end
@@ -56,6 +60,10 @@ class PostAppeal < ActiveRecord::Base
q = q.where("post_id = ?", params[:post_id].to_i)
end
if params[:post_tags_match].present?
q = q.post_tags_match(params[:post_tags_match])
end
if params[:is_resolved] == "true"
q = q.resolved
elsif params[:is_resolved] == "false"

View File

@@ -24,6 +24,10 @@ class PostFlag < ActiveRecord::Base
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
end
def post_tags_match(query)
PostQueryBuilder.new(query).build(self.joins(:post))
end
def resolved
where("is_resolved = ?", true)
end
@@ -64,6 +68,10 @@ class PostFlag < ActiveRecord::Base
q = q.where("post_id = ?", params[:post_id].to_i)
end
if params[:post_tags_match].present?
q = q.post_tags_match(params[:post_tags_match])
end
if params[:is_resolved] == "true"
q = q.resolved
elsif params[:is_resolved] == "false"

View File

@@ -1,5 +1,6 @@
<%= 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 :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 :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] %>

View File

@@ -1,5 +1,6 @@
<%= 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 :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] } %>
<% if CurrentUser.is_moderator? %>
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>