fix #2314 and appeals
This commit is contained in:
@@ -11,6 +11,11 @@ class PostAppeal < ActiveRecord::Base
|
||||
attr_accessible :post_id, :post, :reason
|
||||
|
||||
module SearchMethods
|
||||
def reason_matches(query)
|
||||
query = "*#{query}*" unless query =~ /\*/
|
||||
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
|
||||
end
|
||||
|
||||
def resolved
|
||||
joins(:post).where("posts.is_deleted = false and posts.is_flagged = false")
|
||||
end
|
||||
@@ -35,6 +40,10 @@ class PostAppeal < ActiveRecord::Base
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:reason_matches].present?
|
||||
q = q.reason_matches(params[:reason_matches])
|
||||
end
|
||||
|
||||
if params[:creator_id].present?
|
||||
q = q.for_user(params[:creator_id].to_i)
|
||||
end
|
||||
|
||||
@@ -13,6 +13,11 @@ class PostFlag < ActiveRecord::Base
|
||||
attr_accessor :is_deletion
|
||||
|
||||
module SearchMethods
|
||||
def reason_matches(query)
|
||||
query = "*#{query}*" unless query =~ /\*/
|
||||
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
|
||||
end
|
||||
|
||||
def resolved
|
||||
where("is_resolved = ?", true)
|
||||
end
|
||||
@@ -37,6 +42,10 @@ class PostFlag < ActiveRecord::Base
|
||||
q = where("true")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:reason_matches].present?
|
||||
q = q.reason_matches(params[:reason_matches])
|
||||
end
|
||||
|
||||
if params[:creator_id].present? && (CurrentUser.user.is_janitor? || params[:creator_id].to_i == CurrentUser.user.id)
|
||||
q = q.where("creator_id = ?", params[:creator_id].to_i)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<table class="search">
|
||||
<tbody>
|
||||
<%= form_tag(post_appeals_path, :method => :get, :class => "simple_form") do %>
|
||||
<tr>
|
||||
<th><label for="search_reason_matches">Reason</label></th>
|
||||
<td>
|
||||
<div class="input">
|
||||
<%= text_field "search", "reason_matches", :label => "Reason", :value => params[:search][:reason_matches] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><label for="search_post_id">Post ID</label></th>
|
||||
<td>
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<table class="search">
|
||||
<tbody>
|
||||
<%= form_tag(post_flags_path, :method => :get, :class => "simple_form") do %>
|
||||
<tr>
|
||||
<th><label for="search_reason_matches">Reason</label></th>
|
||||
<td>
|
||||
<div class="input">
|
||||
<%= text_field "search", "reason_matches", :label => "Reason", :value => params[:search][:reason_matches] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><label for="search_post_id">Post ID</label></th>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user