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