From 59aa45e83bfc025daf67b7f72f2d6f532d0f424c Mon Sep 17 00:00:00 2001 From: Toks Date: Wed, 9 Oct 2013 13:05:06 -0400 Subject: [PATCH] fixes #920 --- app/controllers/forum_posts_controller.rb | 2 +- app/controllers/forum_topics_controller.rb | 2 ++ app/views/forum_posts/_forum_post.html.erb | 2 +- app/views/forum_topics/_secondary_links.html.erb | 6 +++++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/forum_posts_controller.rb b/app/controllers/forum_posts_controller.rb index 680470220..aaaf2caf2 100644 --- a/app/controllers/forum_posts_controller.rb +++ b/app/controllers/forum_posts_controller.rb @@ -54,7 +54,7 @@ class ForumPostsController < ApplicationController def destroy @forum_post = ForumPost.find(params[:id]) - raise User::PrivilegeError unless @forum_post.editable_by?(CurrentUser.user) + check_privilege(@forum_post) @forum_post.update_column(:is_deleted, true) respond_with(@forum_post) end diff --git a/app/controllers/forum_topics_controller.rb b/app/controllers/forum_topics_controller.rb index d938308f6..7d299601a 100644 --- a/app/controllers/forum_topics_controller.rb +++ b/app/controllers/forum_topics_controller.rb @@ -49,6 +49,7 @@ class ForumTopicsController < ApplicationController @forum_topic = ForumTopic.find(params[:id]) check_privilege(@forum_topic) @forum_topic.update_column(:is_deleted, true) + flash[:notice] = "Topic deleted" respond_with(@forum_topic) end @@ -56,6 +57,7 @@ class ForumTopicsController < ApplicationController @forum_topic = ForumTopic.find(params[:id]) check_privilege(@forum_topic) @forum_topic.update_column(:is_deleted, false) + flash[:notice] = "Topic undeleted" respond_with(@forum_topic) end diff --git a/app/views/forum_posts/_forum_post.html.erb b/app/views/forum_posts/_forum_post.html.erb index 5aa948025..26266c478 100644 --- a/app/views/forum_posts/_forum_post.html.erb +++ b/app/views/forum_posts/_forum_post.html.erb @@ -23,7 +23,7 @@ <% if CurrentUser.is_member? && @forum_topic %>
  • <%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %>
  • <% end %> - <% if CurrentUser.is_janitor? %> + <% if CurrentUser.is_janitor? && !forum_post.is_original_post? %> <% if forum_post.is_deleted %>
  • <%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %>
  • <% else %> diff --git a/app/views/forum_topics/_secondary_links.html.erb b/app/views/forum_topics/_secondary_links.html.erb index 45942094e..3961594a9 100644 --- a/app/views/forum_topics/_secondary_links.html.erb +++ b/app/views/forum_topics/_secondary_links.html.erb @@ -16,7 +16,11 @@ <% if !@forum_topic.new_record? && @forum_topic.editable_by?(CurrentUser.user) %>
  • <%= link_to "Edit", edit_forum_topic_path(@forum_topic) %>
  • <% if CurrentUser.is_janitor? %> -
  • <%= link_to "Delete", forum_topic_path(@forum_topic), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this forum topic?" %>
  • + <% if @forum_topic.is_deleted? %> +
  • <%= link_to "Undelete", undelete_forum_topic_path(@forum_topic), :method => :post %>
  • + <% else %> +
  • <%= link_to "Delete", forum_topic_path(@forum_topic), :method => :delete, :confirm => "Are you sure you want to delete this forum topic?" %>
  • + <% end %> <% if @forum_topic.is_locked? %>
  • <%= link_to "Unlock", forum_topic_path(@forum_topic, :forum_topic => {:is_locked => false}), :method => :put %>
  • <% else %>