diff --git a/app/assets/javascripts/utility.js b/app/assets/javascripts/utility.js index 379dd828f..5cc0f0134 100644 --- a/app/assets/javascripts/utility.js +++ b/app/assets/javascripts/utility.js @@ -4,19 +4,13 @@ } Danbooru.notice = function(msg) { - $('#notice').html(msg).show(); + $('#notice').html(msg).addClass("ui-state-highlight").removeClass("ui-state-error").show(); } - Danbooru.j_alert = function(title, msg) { - this.notice(msg); - // $('
').html(msg).dialog({modal: true}); + Danbooru.error = function(msg) { + $('#notice').html(msg).removeClass("ui-state-highlight").addClass("ui-state-error").show(); } - - Danbooru.j_error = function(msg) { - this.notice(msg); - // this.j_alert("Error", msg); - } - + Danbooru.ajax_start = function(target) { $(target).after(''); } diff --git a/app/assets/stylesheets/specific/posts.css.scss b/app/assets/stylesheets/specific/posts.css.scss index fac1f1273..dddb7688a 100644 --- a/app/assets/stylesheets/specific/posts.css.scss +++ b/app/assets/stylesheets/specific/posts.css.scss @@ -134,6 +134,10 @@ div#c-posts { section#edit { margin-top: 1em; } + + span.quick-mod { + float: right; + } } div#quick-edit-div { diff --git a/app/controllers/moderator/post/approvals_controller.rb b/app/controllers/moderator/post/approvals_controller.rb index e813eaf93..babd93136 100644 --- a/app/controllers/moderator/post/approvals_controller.rb +++ b/app/controllers/moderator/post/approvals_controller.rb @@ -6,6 +6,7 @@ module Moderator def create @post = ::Post.find(params[:post_id]) @post.approve! + rescue ::Post::ApprovalError end end end diff --git a/app/models/post.rb b/app/models/post.rb index 443859ea2..51e5d9294 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -30,8 +30,8 @@ class Post < ActiveRecord::Base validates_uniqueness_of :md5 validates_presence_of :parent, :if => lambda {|rec| !rec.parent_id.nil?} validate :validate_parent_does_not_have_a_parent - attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at - attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :is_rating_locked, :is_note_locked, :as => [:admin, :moderator, :janitor] + attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id + attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :is_rating_locked, :is_note_locked, :as => [:admin, :moderator, :janitor] scope :pending, where(["is_pending = ?", true]) scope :pending_or_flagged, where(["(is_pending = ? OR is_flagged = ?)", true, true]) scope :undeleted, where(["is_deleted = ?", false]) @@ -292,7 +292,10 @@ class Post < ActiveRecord::Base end def approve! - raise ApprovalError.new("You have previously approved this post and cannot approve it again") if approver_id == CurrentUser.id + if approver_id == CurrentUser.id + errors.add(:approver, "have already approved this post") + raise ApprovalError.new("You have previously approved this post and cannot approve it again") + end flags.each {|x| x.resolve!} self.is_flagged = false @@ -302,6 +305,10 @@ class Post < ActiveRecord::Base save! ModAction.create(:description => "approved post ##{id}") end + + def disapproved_by?(user) + PostDisapproval.where(:user_id => user.id, :post_id => id).exists? + end end module PresenterMethods diff --git a/app/views/moderator/post/approvals/create.js.erb b/app/views/moderator/post/approvals/create.js.erb index b8b15779a..67222d726 100644 --- a/app/views/moderator/post/approvals/create.js.erb +++ b/app/views/moderator/post/approvals/create.js.erb @@ -1,6 +1,16 @@ +<% if @post.errors.any? %> + +Danbooru.error("Error: " + <%= @post.errors.full_messages.join("; ").to_json.html_safe %>); + +<% else %> + $("#c-posts #approve").hide(); $("#c-posts #disapprove").hide(); $("#c-posts #flag").show(); +$("#pending-approval-notice").hide(); + $("#c-post-moderation #post-<%= @post.id %>").hide(); -Danbooru.notice("Post was approved"); \ No newline at end of file +Danbooru.notice("Post was approved"); + +<% end %> \ No newline at end of file diff --git a/app/views/moderator/post/disapprovals/create.js.erb b/app/views/moderator/post/disapprovals/create.js.erb index 344022e77..cebea6fb4 100644 --- a/app/views/moderator/post/disapprovals/create.js.erb +++ b/app/views/moderator/post/disapprovals/create.js.erb @@ -1,12 +1,14 @@ <% if @post_disapproval.errors.any? %> -Danbooru.j_error("Error: " + "<%= j @post_disapproval.errors.full_messages.join("; ") %>"); +Danbooru.error("Error: " + <%= @post_disapproval.errors.full_messages.join("; ").to_json.html_safe %>); <% else %> $("#c-posts #approve").hide(); $("#c-posts #disapprove").hide(); +$("#pending-approval-notice").hide(); + $("#c-post-moderation #post-<%= @post.id %>").hide(); Danbooru.notice("Post was disapproved"); diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index 05104e3d1..189aae8de 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -1,13 +1,36 @@ <% if (post.is_flagged? || post.is_deleted?) && post.flags.any? %> -
- +
This post has been flagged for deletion: <%= post_flag_reasons(post) %>
<% end %> +<% if post.is_pending? %> +
+ This post is pending approval (<%= link_to "learn more", wiki_pages_path(:title => "help:post_moderation") %>) + + <% if CurrentUser.is_janitor? && !post.disapproved_by?(CurrentUser.user) %> + + <%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :method => :post, :remote => true %> + | <%= link_to "Disapprove", moderator_post_disapproval_path(:post_id => post.id), :method => :post, :remote => true %> + + <% end %> +
+<% end %> + <% if post.appeals.any? %>
- This post has been appealed: <%= post_appeal_reasons(post) %>
+<% end %> + +<% if post.parent_id %> +
+ This post belongs to a <%= link_to "parent", post_path(post.parent_id) %> (<%= link_to "learn more", wiki_pages_path(:title => "help:post_relationships") %>) +
+<% end %> + +<% if post.has_children? %> +
+ This post has <%= link_to "children", posts_path(:tags => "parent:#{post.id}") %> (<%= link_to "learn more", wiki_pages_path(:title => "help:post_relationships") %>) +
<% end %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 235992646..8c18d4c1f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5,6 +5,9 @@ en: hello: "Hello world" activerecord: attributes: + post: + approver: "You" + approver_id: "You" post_flag: creator: "You" creator_id: "You"