diff --git a/app/assets/javascripts/post_mode_menu.js b/app/assets/javascripts/post_mode_menu.js index da4102174..b9d7a7e05 100644 --- a/app/assets/javascripts/post_mode_menu.js +++ b/app/assets/javascripts/post_mode_menu.js @@ -164,6 +164,8 @@ Danbooru.Post.update(post_id, {"post[is_note_locked]": "1"}); } else if (s === 'approve') { Danbooru.Post.approve(post_id); + } else if (s === 'ban') { + Danbooru.Post.ban(post_id); } else if (s === "tag-script") { var current_script_id = Danbooru.Cookie.get("current_tag_script_id"); var tag_script = Danbooru.Cookie.get("tag-script-" + current_script_id); diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 9ed865e17..f1e82a144 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -502,7 +502,22 @@ error: function(data) { Danbooru.Post.notice_update("dec"); Danbooru.error('There was an error updating post #' + post_id + ''); - $("#post_" + post_id).effect("shake", {distance: 5, times: 1}, 100); + } + }); + } + + Danbooru.Post.ban = function(post_id) { + $.ajax({ + type: "POST", + url: "/moderator/post/posts/" + post_id + "/ban.js", + data: { + commit: "Ban" + }, + success: function(data) { + $("#post_" + post_id).remove(); + }, + error: function(data) { + Danbooru.error('There was an error updating post #' + post_id + ''); } }); } diff --git a/app/assets/stylesheets/specific/post_mode_menu.css.scss b/app/assets/stylesheets/specific/post_mode_menu.css.scss index 0524b1e6a..091009f68 100644 --- a/app/assets/stylesheets/specific/post_mode_menu.css.scss +++ b/app/assets/stylesheets/specific/post_mode_menu.css.scss @@ -62,6 +62,10 @@ body.mode-translation { background-color: #5CD; } +body.mode-ban { + background-color: #F33; +} + #page, #top, #page-footer { background-color: white; } diff --git a/app/controllers/moderator/post/posts_controller.rb b/app/controllers/moderator/post/posts_controller.rb index 83b3584d0..fad60517b 100644 --- a/app/controllers/moderator/post/posts_controller.rb +++ b/app/controllers/moderator/post/posts_controller.rb @@ -51,7 +51,14 @@ module Moderator if params[:commit] == "Ban" @post.ban! end - redirect_to(post_path(@post), :notice => "Post was banned") + + respond_to do |fmt| + fmt.html do + redirect_to(post_path(@post), :notice => "Post was banned") + end + + fmt.js + end end def unban diff --git a/app/views/moderator/post/posts/ban.js.erb b/app/views/moderator/post/posts/ban.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/posts/partials/index/_mode_menu.html.erb b/app/views/posts/partials/index/_mode_menu.html.erb index 9d241e74f..692b7542c 100644 --- a/app/views/posts/partials/index/_mode_menu.html.erb +++ b/app/views/posts/partials/index/_mode_menu.html.erb @@ -20,6 +20,9 @@ <% if CurrentUser.can_approve_posts? %> <% end %> + <% if CurrentUser.is_admin? %> + + <% end %>