From af22c2b7fa234388d0241196c185b657b174adf9 Mon Sep 17 00:00:00 2001 From: Toks Date: Sat, 5 Dec 2015 16:18:49 -0500 Subject: [PATCH] Display expunge errors #2556 --- app/controllers/moderator/post/posts_controller.rb | 2 ++ app/views/moderator/post/posts/expunge.js.erb | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/moderator/post/posts_controller.rb b/app/controllers/moderator/post/posts_controller.rb index e685a8f2c..ffc0c8a79 100644 --- a/app/controllers/moderator/post/posts_controller.rb +++ b/app/controllers/moderator/post/posts_controller.rb @@ -38,6 +38,8 @@ module Moderator def expunge @post = ::Post.find(params[:id]) @post.expunge! + rescue StandardError => x + @error = x end def confirm_ban diff --git a/app/views/moderator/post/posts/expunge.js.erb b/app/views/moderator/post/posts/expunge.js.erb index 40db184cf..66f89341d 100644 --- a/app/views/moderator/post/posts/expunge.js.erb +++ b/app/views/moderator/post/posts/expunge.js.erb @@ -1 +1,7 @@ -Danbooru.notice("Post was permanently deleted"); +<% if @post.errors.any? %> + Danbooru.error("<%= j @post.errors.full_messages.join('; ') %>"); +<% elsif @error %> + Danbooru.error("<%= j @error.to_s %>"); +<% else %> + Danbooru.notice("Post was permanently deleted"); +<% end %>