fixes #2428
This commit is contained in:
@@ -56,7 +56,7 @@ class CommentsController < ApplicationController
|
||||
def destroy
|
||||
@comment = Comment.find(params[:id])
|
||||
check_privilege(@comment)
|
||||
@comment.destroy
|
||||
@comment.delete!
|
||||
respond_with(@comment) do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
@@ -171,6 +171,10 @@ class Comment < ActiveRecord::Base
|
||||
def hidden_attributes
|
||||
super + [:body_index]
|
||||
end
|
||||
|
||||
def delete!
|
||||
update_attribute(:is_deleted, true)
|
||||
end
|
||||
end
|
||||
|
||||
Comment.connection.extend(PostgresExtensions)
|
||||
|
||||
@@ -1 +1 @@
|
||||
$(".comment[data-comment-id=<%= @comment.id %>]").remove();
|
||||
$(".comment[data-comment-id=<%= @comment.id %>] div.author h1").append(" (deleted)");
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
<article class="comment" data-post-id="<%= comment.post_id %>" data-comment-id="<%= comment.id %>" data-score="<%= comment.score %>" data-creator="<%= comment.creator.name %>">
|
||||
<% if CurrentUser.is_moderator? || !comment.is_deleted? %>
|
||||
<article class="comment" data-post-id="<%= comment.post_id %>" data-comment-id="<%= comment.id %>" data-score="<%= comment.score %>" data-creator="<%= comment.creator.name %>">
|
||||
<div class="author">
|
||||
<h1><%= link_to_user comment.creator %></h1>
|
||||
<h1>
|
||||
<%= link_to_user comment.creator %>
|
||||
<% if comment.is_deleted? %>
|
||||
(deleted)
|
||||
<% end %>
|
||||
</h1>
|
||||
<p>
|
||||
<%= time_ago_in_words_tagged(comment.created_at) %>
|
||||
</p>
|
||||
@@ -33,4 +39,5 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</article>
|
||||
</article>
|
||||
<% end %>
|
||||
|
||||
6
db/migrate/20150705014135_add_is_deleted_to_comments.rb
Normal file
6
db/migrate/20150705014135_add_is_deleted_to_comments.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AddIsDeletedToComments < ActiveRecord::Migration
|
||||
def change
|
||||
execute "set statement_timeout = 0"
|
||||
add_column :comments, :is_deleted, :boolean, :null => false, :default => false
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user