implemented post moderation
This commit is contained in:
@@ -4,7 +4,7 @@ class PostModerationController < ApplicationController
|
||||
rescue_from Post::DisapprovalError, :with => :disapproval_error
|
||||
|
||||
def moderate
|
||||
@search = Post.pending.available_for_moderation.search(params[:search]).order("id asc")
|
||||
@search = Post.order("id asc").pending.available_for_moderation.search(:tag_match => params[:query])
|
||||
@posts = @search.paginate(:page => params[:page])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
||||
@@ -35,6 +35,7 @@ class Post < ActiveRecord::Base
|
||||
scope :hidden_from_moderation, lambda {where(["id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
|
||||
scope :before_id, lambda {|id| id.present? ? where(["posts.id < ?", id]) : where("TRUE")}
|
||||
scope :tag_match, lambda {|query| Post.tag_match_helper(query)}
|
||||
search_method :tag_match
|
||||
|
||||
module FileMethods
|
||||
def delete_files
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
Danbooru.j_error(<%= @exception.message.to_json.html_safe %>);
|
||||
$("img#approve-wait").hide();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
$("a#approve").hide();
|
||||
$("a#disapprove").hide();
|
||||
$("a#unapprove").show();
|
||||
$("img#approve-wait").hide();
|
||||
$("#c-posts a#approve").hide();
|
||||
$("#c-posts a#disapprove").hide();
|
||||
$("#c-posts a#unapprove").show();
|
||||
|
||||
$("#c-post-moderation #post-<%= @post.id %>").hide();
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
Danbooru.j_error("You have already disapproved this post");
|
||||
$("img#disapprove-wait").hide();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
$("a#approve").hide();
|
||||
$("a#disapprove").hide();
|
||||
$("a#unapprove").hide();
|
||||
$("img#disapprove-wait").hide();
|
||||
$("#c-posts a#approve").hide();
|
||||
$("#c-posts a#disapprove").hide();
|
||||
$("#c-posts a#unapprove").hide();
|
||||
|
||||
$("#c-post-moderation #post-<%= @post.id %>").hide();
|
||||
|
||||
@@ -1,70 +1,39 @@
|
||||
<div id="search">
|
||||
<%= simple_form_for(@search) do |f| %>
|
||||
<%= f.input "tags_match", :input_html => {:size => 40}, :label => false %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 2em;">
|
||||
<h2>Moderation Queue</h2>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
<div>
|
||||
<div>
|
||||
<%= link_to(image_tag(post.medium_file_url), post_path(post)) %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<ul>
|
||||
<li>Rating: <%= post.pretty_rating %></li>
|
||||
<li>Score: <%= post.score %></li>
|
||||
<li>Uploader: <%= link_to(post.uploader.name, user_path(post.uploader_id)) %> <%= time_ago_in_words(post.updated_at) %> ago</li>
|
||||
<% if post.is_flagged? %>
|
||||
<li>Flagged: <%= post.unapproval.reason %> by <%= post.unapproval.unapprover.name %></li>
|
||||
<% end %>
|
||||
<li>Hidden: <%= post.disapprovals.count %></li>
|
||||
<li>Tags: <%= post.tag_string %></li>
|
||||
<% if post.pools.any? %>
|
||||
<li>Pools: </li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
<% @posts.each do |p| %>
|
||||
<tr id="mod-row-<%= p.id %>" class="<% if p.cached_tags =~ /(^| )duplicate($| )/ %>dupe<% elsif p.score > 2 %>good<% elsif p.score < -2 %>bad<% else %><%= cycle 'even', 'odd' %><% end %>">
|
||||
<td width="10%"><%= fast_link_to image_tag(p.preview_url, :class => (p.status == "flagged" ? "flagged" : nil), :width => p.preview_dimensions[0], :height => p.preview_dimensions[1]), {:controller => "post", :action => "show", :id => p.id}, :target => "_blank" %></td>
|
||||
<td width="90%">
|
||||
<ul>
|
||||
<li>
|
||||
<%= link_to_function "Approve", "Post.moderate(#{p.id}, 'Approve')" %> |
|
||||
<% if @current_user.is_janitor_or_higher? %>
|
||||
<%= link_to_function "Delete", "Post.moderate(#{p.id}, 'Delete')" %> |
|
||||
<% end %>
|
||||
<%= link_to_function "Hide", "Post.moderate(#{p.id}, 'Hide')" %>
|
||||
</li>
|
||||
<li>Rating: <%= p.pretty_rating %></li>
|
||||
<li>Hidden: <%= p.mod_hidden_count %></li>
|
||||
<% if p.pools.any? %>
|
||||
<li>Pools: <%= h p.pools.map {|x| x.pretty_name}.join(", ") %></li>
|
||||
<% end %>
|
||||
<% if p.parent_id %>
|
||||
<li>Parent: <%= fast_link_to p.parent_id, :action => "moderate", :query => "parent:#{p.parent_id}" %></li>
|
||||
<% end %>
|
||||
<li>Tags: <%= h p.cached_tags %></li>
|
||||
<li>Score: <span id="post-score-<%= p.id %>"><%= p.score %></span> (vote <%= link_to_function "down", "Post.vote(-1, #{p.id})" %>)</li>
|
||||
<% if p.flag_detail && p.flag_detail.reason %>
|
||||
<li>Flagged: <%= h p.flag_detail.reason %></li>
|
||||
<% end %>
|
||||
<li>Uploaded by <%= fast_link_to h(p.author), :controller => "user", :action => "show", :id => p.user_id %> <%= time_ago_in_words(p.created_at) %> ago (<%= fast_link_to "mod", :action => "moderate", :query => "user:#{p.author}" %>)</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<div id="c-post-moderation">
|
||||
<div id="a-moderate">
|
||||
<div id="search">
|
||||
<%= form_tag(post_moderation_moderate_path, :method => :get) do %>
|
||||
<%= text_field_tag "query", params[:query], :size => 40 %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>Moderation Queue</h2>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
<article id="post-<%= post.id %>">
|
||||
<aside>
|
||||
<%= link_to(image_tag(post.medium_file_url), post_path(post)) %>
|
||||
</aside>
|
||||
|
||||
<section>
|
||||
<ul>
|
||||
<li><%= link_to "Approve", post_moderation_approve_path(:post_id => post.id), :remote => true, :method => :put %> | <%= link_to "Disapprove", post_moderation_disapprove_path(:post_id => post.id), :remote => true, :method => :put %></li>
|
||||
<li>Rating: <%= post.pretty_rating %></li>
|
||||
<li>Score: <%= post.score %></li>
|
||||
<li>Uploader: <%= link_to(post.uploader.name, user_path(post.uploader_id)) %> <%= time_ago_in_words(post.created_at) %> ago</li>
|
||||
<% if post.is_flagged? %>
|
||||
<li>Flagged: <%= post.unapproval.reason %> by <%= post.unapproval.unapprover.name %></li>
|
||||
<% end %>
|
||||
<li>Disapprovals: <%= post.disapprovals.count %></li>
|
||||
<li>Tags: <%= post.tag_string %></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
</article>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render :partial => "footer" %>
|
||||
|
||||
@@ -13,6 +13,24 @@
|
||||
(<%= post.image_width %>x<%= post.image_height %>)
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
Status:
|
||||
<% if post.is_pending? %>
|
||||
<abbr title="Pending">P</abbr>
|
||||
<% end %>
|
||||
|
||||
<% if post.is_deleted? %>
|
||||
<abbr title="Deleted">D</abbr>
|
||||
<% end %>
|
||||
|
||||
<% if post.is_flagged? %>
|
||||
<abbr title="Unapproved">U</abbr>
|
||||
<% end %>
|
||||
|
||||
<% if !post.is_pending? && !post.is_deleted? %>
|
||||
<abbr title="Active">A</abbr>
|
||||
<% end %>
|
||||
</li>
|
||||
<li><%= link_to "Tag History", post_versions_path(:search => {:post_id_eq => post.id}) %></li>
|
||||
<li><%= link_to "Note History", note_versions_path(:search => {:post_id_eq => post.id}) %></li>
|
||||
</ul>
|
||||
@@ -506,3 +506,13 @@ div#c-wiki-pages div#form-aside {
|
||||
div#c-wiki-pages div#a-edit textarea, div#c-wiki-pages div#a-new textarea {
|
||||
width: 400px;
|
||||
height: 40em; }
|
||||
|
||||
/*** Post Moderation ***/
|
||||
div#c-post-moderation article {
|
||||
margin-bottom: 4em; }
|
||||
div#c-post-moderation aside {
|
||||
float: left;
|
||||
width: 520px; }
|
||||
div#c-post-moderation section {
|
||||
float: left;
|
||||
width: 300px; }
|
||||
|
||||
@@ -867,3 +867,22 @@ div#c-wiki-pages {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Post Moderation ***/
|
||||
div#c-post-moderation {
|
||||
article {
|
||||
margin-bottom: 4em;
|
||||
}
|
||||
|
||||
aside {
|
||||
float: left;
|
||||
width: 520px;
|
||||
}
|
||||
|
||||
section {
|
||||
float: left;
|
||||
width: 300px;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user