fix setting parent_id, add approval status notices on top of post/show
This commit is contained in:
@@ -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);
|
||||
// $('<div title="' + title + '"></div>').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('<img src="/images/wait.gif" width="15" height="5" class="wait">');
|
||||
}
|
||||
|
||||
@@ -134,6 +134,10 @@ div#c-posts {
|
||||
section#edit {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
span.quick-mod {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
div#quick-edit-div {
|
||||
|
||||
@@ -6,6 +6,7 @@ module Moderator
|
||||
def create
|
||||
@post = ::Post.find(params[:post_id])
|
||||
@post.approve!
|
||||
rescue ::Post::ApprovalError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
Danbooru.notice("Post was approved");
|
||||
|
||||
<% end %>
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -1,13 +1,36 @@
|
||||
<% if (post.is_flagged? || post.is_deleted?) && post.flags.any? %>
|
||||
<div class="ui-corner-all ui-state-error notice">
|
||||
<span class="ui-icon ui-icon-alert"></span>
|
||||
<div class="ui-corner-all ui-state-highlight notice">
|
||||
This post has been flagged for deletion: <%= post_flag_reasons(post) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if post.is_pending? %>
|
||||
<div class="ui-corner-all ui-state-highlight notice" id="pending-approval-notice">
|
||||
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) %>
|
||||
<span class="quick-mod">
|
||||
<%= 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 %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if post.appeals.any? %>
|
||||
<div class="ui-corner-all ui-state-highlight notice">
|
||||
<span class="ui-icon ui-icon-info"></span>
|
||||
This post has been appealed: <%= post_appeal_reasons(post) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if post.parent_id %>
|
||||
<div class="ui-corner-all ui-state-highlight notice">
|
||||
This post belongs to a <%= link_to "parent", post_path(post.parent_id) %> (<%= link_to "learn more", wiki_pages_path(:title => "help:post_relationships") %>)
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if post.has_children? %>
|
||||
<div class="ui-corner-all ui-state-highlight notice">
|
||||
This post has <%= link_to "children", posts_path(:tags => "parent:#{post.id}") %> (<%= link_to "learn more", wiki_pages_path(:title => "help:post_relationships") %>)
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -5,6 +5,9 @@ en:
|
||||
hello: "Hello world"
|
||||
activerecord:
|
||||
attributes:
|
||||
post:
|
||||
approver: "You"
|
||||
approver_id: "You"
|
||||
post_flag:
|
||||
creator: "You"
|
||||
creator_id: "You"
|
||||
|
||||
Reference in New Issue
Block a user