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
|
||||
|
||||
Reference in New Issue
Block a user