From 0830eb46c131cf52e1c52f540966c05563d32b47 Mon Sep 17 00:00:00 2001 From: albert Date: Mon, 14 Mar 2011 14:08:29 -0400 Subject: [PATCH] implemented post moderation --- app/controllers/post_moderation_controller.rb | 2 +- app/models/post.rb | 1 + .../post_moderation/approval_error.js.erb | 1 - app/views/post_moderation/approve.js.erb | 9 +- .../post_moderation/disapproval_error.js.erb | 1 - app/views/post_moderation/disapprove.js | 9 +- app/views/post_moderation/moderate.html.erb | 103 ++++++------------ .../posts/partials/show/_information.html.erb | 18 +++ public/stylesheets/compiled/default.css | 10 ++ public/stylesheets/src/default.scss | 19 ++++ 10 files changed, 95 insertions(+), 78 deletions(-) diff --git a/app/controllers/post_moderation_controller.rb b/app/controllers/post_moderation_controller.rb index 3754889bf..81441aec5 100644 --- a/app/controllers/post_moderation_controller.rb +++ b/app/controllers/post_moderation_controller.rb @@ -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 diff --git a/app/models/post.rb b/app/models/post.rb index 379eb3599..d92e79ac4 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/views/post_moderation/approval_error.js.erb b/app/views/post_moderation/approval_error.js.erb index e041ae9b2..2879b7389 100644 --- a/app/views/post_moderation/approval_error.js.erb +++ b/app/views/post_moderation/approval_error.js.erb @@ -1,2 +1 @@ Danbooru.j_error(<%= @exception.message.to_json.html_safe %>); -$("img#approve-wait").hide(); diff --git a/app/views/post_moderation/approve.js.erb b/app/views/post_moderation/approve.js.erb index cfa41fb5a..8fd8515ef 100644 --- a/app/views/post_moderation/approve.js.erb +++ b/app/views/post_moderation/approve.js.erb @@ -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(); diff --git a/app/views/post_moderation/disapproval_error.js.erb b/app/views/post_moderation/disapproval_error.js.erb index 2c8ec16df..e96e2214d 100644 --- a/app/views/post_moderation/disapproval_error.js.erb +++ b/app/views/post_moderation/disapproval_error.js.erb @@ -1,2 +1 @@ Danbooru.j_error("You have already disapproved this post"); -$("img#disapprove-wait").hide(); diff --git a/app/views/post_moderation/disapprove.js b/app/views/post_moderation/disapprove.js index 93c4ad456..dcbb075ed 100644 --- a/app/views/post_moderation/disapprove.js +++ b/app/views/post_moderation/disapprove.js @@ -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(); diff --git a/app/views/post_moderation/moderate.html.erb b/app/views/post_moderation/moderate.html.erb index e5c6f5c16..25f7114bd 100644 --- a/app/views/post_moderation/moderate.html.erb +++ b/app/views/post_moderation/moderate.html.erb @@ -1,70 +1,39 @@ - - -
-

Moderation Queue

- - <% @posts.each do |post| %> -
-
- <%= link_to(image_tag(post.medium_file_url), post_path(post)) %> -
- -
-
    -
  • Rating: <%= post.pretty_rating %>
  • -
  • Score: <%= post.score %>
  • -
  • Uploader: <%= link_to(post.uploader.name, user_path(post.uploader_id)) %> <%= time_ago_in_words(post.updated_at) %> ago
  • - <% if post.is_flagged? %> -
  • Flagged: <%= post.unapproval.reason %> by <%= post.unapproval.unapprover.name %>
  • - <% end %> -
  • Hidden: <%= post.disapprovals.count %>
  • -
  • Tags: <%= post.tag_string %>
  • - <% if post.pools.any? %> -
  • Pools:
  • - <% end %> -
-
-
- <% end %> - - - - <% @posts.each do |p| %> - - - - +
+
+
-
<%= 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" %> -
    -
  • - <%= 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')" %> -
  • -
  • Rating: <%= p.pretty_rating %>
  • -
  • Hidden: <%= p.mod_hidden_count %>
  • - <% if p.pools.any? %> -
  • Pools: <%= h p.pools.map {|x| x.pretty_name}.join(", ") %>
  • - <% end %> - <% if p.parent_id %> -
  • Parent: <%= fast_link_to p.parent_id, :action => "moderate", :query => "parent:#{p.parent_id}" %>
  • - <% end %> -
  • Tags: <%= h p.cached_tags %>
  • -
  • Score: <%= p.score %> (vote <%= link_to_function "down", "Post.vote(-1, #{p.id})" %>)
  • - <% if p.flag_detail && p.flag_detail.reason %> -
  • Flagged: <%= h p.flag_detail.reason %>
  • - <% end %> -
  • 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}" %>)
  • -
-
+
+ +
+

Moderation Queue

+ + <% @posts.each do |post| %> +
+ + +
+
    +
  • <%= 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 %>
  • +
  • Rating: <%= post.pretty_rating %>
  • +
  • Score: <%= post.score %>
  • +
  • Uploader: <%= link_to(post.uploader.name, user_path(post.uploader_id)) %> <%= time_ago_in_words(post.created_at) %> ago
  • + <% if post.is_flagged? %> +
  • Flagged: <%= post.unapproval.reason %> by <%= post.unapproval.unapprover.name %>
  • + <% end %> +
  • Disapprovals: <%= post.disapprovals.count %>
  • +
  • Tags: <%= post.tag_string %>
  • +
+
+ +
+
+ <% end %> +
+ -<%= render :partial => "footer" %> diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index ac76aab4d..8c5a04d8a 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -13,6 +13,24 @@ (<%= post.image_width %>x<%= post.image_height %>) <% end %> +
  • + Status: + <% if post.is_pending? %> + P + <% end %> + + <% if post.is_deleted? %> + D + <% end %> + + <% if post.is_flagged? %> + U + <% end %> + + <% if !post.is_pending? && !post.is_deleted? %> + A + <% end %> +
  • <%= link_to "Tag History", post_versions_path(:search => {:post_id_eq => post.id}) %>
  • <%= link_to "Note History", note_versions_path(:search => {:post_id_eq => post.id}) %>
  • \ No newline at end of file diff --git a/public/stylesheets/compiled/default.css b/public/stylesheets/compiled/default.css index cd97f130b..db769864a 100644 --- a/public/stylesheets/compiled/default.css +++ b/public/stylesheets/compiled/default.css @@ -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; } diff --git a/public/stylesheets/src/default.scss b/public/stylesheets/src/default.scss index b15330146..3ad0a7e0a 100644 --- a/public/stylesheets/src/default.scss +++ b/public/stylesheets/src/default.scss @@ -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; + } +} \ No newline at end of file