pundit: convert forum topics / forum posts to pundit.
Fix it being possible for users to delete or undelete their own forum posts and topics, even if they were deleted by a mod.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<% if forum_post.visible?(CurrentUser.user, ActiveModel::Type::Boolean.new.cast(params.dig(:search, :is_deleted))) %>
|
||||
<% if policy(forum_post).show_deleted? %>
|
||||
<article class="forum-post message" id="forum_post_<%= forum_post.id %>"
|
||||
data-forum-post-id="<%= forum_post.id %>"
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
@@ -20,17 +20,17 @@
|
||||
</div>
|
||||
<%= render "application/update_notice", record: forum_post %>
|
||||
<menu>
|
||||
<% if CurrentUser.is_member? && @forum_topic %>
|
||||
<% if policy(forum_post).create? %>
|
||||
<li><%= link_to "Reply", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %></li>
|
||||
<% end %>
|
||||
<% if CurrentUser.is_moderator? && !forum_post.is_original_post?(original_forum_post_id) %>
|
||||
<% if policy(forum_post).destroy? && !forum_post.is_original_post?(original_forum_post_id) %>
|
||||
<% if forum_post.is_deleted %>
|
||||
<li><%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Delete", forum_post_path(forum_post.id), :data => {:confirm => "Are you sure you want to delete this forum post?"}, :method => :delete, :remote => true %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if forum_post.editable_by?(CurrentUser.user) %>
|
||||
<% if policy(forum_post).update? %>
|
||||
<% if forum_post.is_original_post?(original_forum_post_id) %>
|
||||
<li><%= link_to "Edit", edit_forum_topic_path(forum_post.topic), :id => "edit_forum_topic_link_#{forum_post.topic.id}", :class => "edit_forum_topic_link" %></li>
|
||||
<% else %>
|
||||
@@ -46,7 +46,7 @@
|
||||
</ul>
|
||||
<% end %>
|
||||
</menu>
|
||||
<% if forum_post.editable_by?(CurrentUser.user) %>
|
||||
<% if policy(forum_post).update? %>
|
||||
<% if forum_post.is_original_post?(original_forum_post_id) %>
|
||||
<%= render "forum_topics/form", :forum_topic => forum_post.topic %>
|
||||
<% else %>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div id="c-forum-posts">
|
||||
<div id="a-new">
|
||||
<% if @forum_topic %>
|
||||
<h1>Reply to <%= @forum_topic.title %></h1>
|
||||
<% if @forum_post.topic.present? %>
|
||||
<h1>Reply to <%= @forum_post.topic.title %></h1>
|
||||
<% else %>
|
||||
<h1>New Forum Post</h1>
|
||||
<% end %>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%= error_messages_for("forum_post") %>
|
||||
|
||||
<%= edit_form_for(forum_post) do |f| %>
|
||||
<% if @forum_topic %>
|
||||
<% if forum_post.topic_id.present? %>
|
||||
<%= f.input :topic_id, :as => :hidden %>
|
||||
<% else %>
|
||||
<%= f.input :topic_id, :label => "Topic ID" %>
|
||||
|
||||
Reference in New Issue
Block a user