@@ -10,6 +10,14 @@ class PostAppeal < ActiveRecord::Base
|
|||||||
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post"
|
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post"
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
|
def resolved
|
||||||
|
joins(:post).where("posts.is_deleted = false and posts.is_flagged = false")
|
||||||
|
end
|
||||||
|
|
||||||
|
def unresolved
|
||||||
|
joins(:post).where("posts.is_deleted = true or posts.is_flagged = true")
|
||||||
|
end
|
||||||
|
|
||||||
def for_user(user_id)
|
def for_user(user_id)
|
||||||
where("creator_id = ?", user_id)
|
where("creator_id = ?", user_id)
|
||||||
end
|
end
|
||||||
@@ -34,6 +42,12 @@ 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[:is_resolved] == "true"
|
||||||
|
q = q.resolved
|
||||||
|
elsif params[:is_resolved] == "false"
|
||||||
|
q = q.unresolved
|
||||||
|
end
|
||||||
|
|
||||||
q
|
q
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<table class="search">
|
<table class="search">
|
||||||
<tbody>
|
<tbody>
|
||||||
<%= form_tag(post_flags_path, :method => :get, :class => "simple_form") do %>
|
<%= form_tag(post_appeals_path, :method => :get, :class => "simple_form") do %>
|
||||||
<tr>
|
<tr>
|
||||||
<th><label for="search_post_id">Post ID</label></th>
|
<th><label for="search_post_id">Post ID</label></th>
|
||||||
<td>
|
<td>
|
||||||
@@ -19,6 +19,15 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><label for="search_is_resolved">Resolved</label></th>
|
||||||
|
<td>
|
||||||
|
<div class="input">
|
||||||
|
<%= select "search", "is_resolved", ["true", "false"], :selected => params[:search][:is_resolved], :include_blank => true %>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= submit_tag "Search" %><td>
|
<td><%= submit_tag "Search" %><td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user