Fix mode menu 'approve' option.
* Fix routing error in respond_with (didn't use /moderator namespace). * Fix /moderator/posts/approvals.json response to return full PostApproval object, not just a success/failure message. * Simplify the javascript a bit (use $.post instead of $.ajax).
This commit is contained in:
@@ -512,23 +512,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Post.approve = function(post_id) {
|
Danbooru.Post.approve = function(post_id) {
|
||||||
$.ajax({
|
$.post(
|
||||||
type: "POST",
|
"/moderator/post/approval.json",
|
||||||
url: "/moderator/post/approval.json",
|
{"post_id": post_id}
|
||||||
data: {"post_id": post_id},
|
).fail(function(data) {
|
||||||
dataType: "json",
|
var message = $.map(data.responseJSON.errors, function(msg, attr) { return msg; }).join("; ");
|
||||||
success: function(data) {
|
Danbooru.error("Error: " + message);
|
||||||
if (!data.success) {
|
}).done(function(data) {
|
||||||
Danbooru.error("Error: " + data.reason);
|
var $post = $("#post_" + post_id);
|
||||||
} else {
|
if ($post.length) {
|
||||||
var $post = $("#post_" + post_id);
|
$post.data("flags", $post.data("flags").replace(/pending/, ""));
|
||||||
if ($post.length) {
|
$post.removeClass("post-status-pending");
|
||||||
$post.data("flags", $post.data("flags").replace(/pending/, ""));
|
Danbooru.notice("Approved post #" + post_id);
|
||||||
$post.removeClass("post-status-pending");
|
|
||||||
}
|
|
||||||
Danbooru.notice("Approved post #" + post_id);
|
|
||||||
$("#pending-approval-notice").hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ module Moderator
|
|||||||
cookies.permanent[:moderated] = Time.now.to_i
|
cookies.permanent[:moderated] = Time.now.to_i
|
||||||
post = ::Post.find(params[:post_id])
|
post = ::Post.find(params[:post_id])
|
||||||
@approval = post.approve!
|
@approval = post.approve!
|
||||||
respond_with(@approval)
|
respond_with(:moderator, @approval)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
{"success": <%= @post.errors.empty? %>, "reason": <%= raw @post.errors.full_messages.join("; ").to_json %>}
|
|
||||||
Reference in New Issue
Block a user