restrict deleting forum posts to janitors
This commit is contained in:
@@ -43,7 +43,7 @@ class ForumPostsController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@forum_post = ForumPost.find(params[:id])
|
@forum_post = ForumPost.find(params[:id])
|
||||||
check_privilege(@forum_post)
|
raise User::PrivilegeError unless CurrentUser.is_janitor?
|
||||||
@forum_post.update_attribute(:is_deleted, true)
|
@forum_post.update_attribute(:is_deleted, true)
|
||||||
respond_with(@forum_post)
|
respond_with(@forum_post)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<% if CurrentUser.is_janitor? || !forum_post.is_deleted? %>
|
||||||
<article data-forum-post-id="<%= forum_post.id %>">
|
<article data-forum-post-id="<%= forum_post.id %>">
|
||||||
<div class="author">
|
<div class="author">
|
||||||
<h4>
|
<h4>
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %></li>
|
<li><%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %></li>
|
||||||
<% if CurrentUser.user.is_janitor? || CurrentUser.user.id == forum_post.creator_id %>
|
<% if CurrentUser.user.is_janitor? %>
|
||||||
<% if forum_post.is_deleted %>
|
<% if forum_post.is_deleted %>
|
||||||
<li><%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %></li>
|
<li><%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
@@ -28,3 +29,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</article>
|
</article>
|
||||||
|
<% end %>
|
||||||
Reference in New Issue
Block a user