Add resolved search for appeals

fixes #1258
This commit is contained in:
Toks
2013-08-04 11:57:27 -04:00
parent 7c11fd440b
commit c6cf19b390
2 changed files with 24 additions and 1 deletions

View File

@@ -10,6 +10,14 @@ class PostAppeal < ActiveRecord::Base
validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post"
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)
where("creator_id = ?", user_id)
end
@@ -34,6 +42,12 @@ class PostAppeal < ActiveRecord::Base
q = q.where("post_id = ?", params[:post_id].to_i)
end
if params[:is_resolved] == "true"
q = q.resolved
elsif params[:is_resolved] == "false"
q = q.unresolved
end
q
end
end

View File

@@ -1,6 +1,6 @@
<table class="search">
<tbody>
<%= form_tag(post_flags_path, :method => :get, :class => "simple_form") do %>
<%= form_tag(post_appeals_path, :method => :get, :class => "simple_form") do %>
<tr>
<th><label for="search_post_id">Post ID</label></th>
<td>
@@ -19,6 +19,15 @@
</td>
</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>
<td><%= submit_tag "Search" %><td>
</tr>