Fix thumbnail appearing next to deleted comments

This commit is contained in:
Toks
2015-07-23 09:57:13 -04:00
parent 95e10e3acd
commit 52c73efc28
3 changed files with 24 additions and 16 deletions

View File

@@ -32,6 +32,10 @@ class Comment < ActiveRecord::Base
where("score >= ?", user.comment_threshold) where("score >= ?", user.comment_threshold)
end end
def undeleted
where("is_deleted = false")
end
def post_tags_match(query) def post_tags_match(query)
PostQueryBuilder.new(query).build(self.joins(:post)).reorder("") PostQueryBuilder.new(query).build(self.joins(:post)).reorder("")
end end

View File

@@ -5,6 +5,7 @@
<div class="comments-for-post"> <div class="comments-for-post">
<div class="list-of-comments"> <div class="list-of-comments">
<% @comments.each do |comment| %> <% @comments.each do |comment| %>
<% if CurrentUser.is_moderator? || !comment.is_deleted? %>
<div id="post_<%= comment.post.id %>" class="post <%= PostPresenter.preview_class(comment.post) %>" <%= PostPresenter.data_attributes(comment.post) %>> <div id="post_<%= comment.post.id %>" class="post <%= PostPresenter.preview_class(comment.post) %>" <%= PostPresenter.data_attributes(comment.post) %>>
<div class="preview"> <div class="preview">
<% if comment.post.visible? %> <% if comment.post.visible? %>
@@ -15,6 +16,7 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<% end %> <% end %>
<% end %>
</div> </div>
</div> </div>

View File

@@ -12,6 +12,7 @@
<% end %> <% end %>
<% @posts.select {|x| x.visible?}.each do |post| %> <% @posts.select {|x| x.visible?}.each do |post| %>
<% if CurrentUser.is_moderator? || post.comments.undeleted.exists? %>
<div id="post_<%= post.id %>" class="post <%= PostPresenter.preview_class(post) %>" <%= PostPresenter.data_attributes(post) %>> <div id="post_<%= post.id %>" class="post <%= PostPresenter.preview_class(post) %>" <%= PostPresenter.data_attributes(post) %>>
<div class="preview"> <div class="preview">
<% if post.visible? %> <% if post.visible? %>
@@ -22,6 +23,7 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<% end %> <% end %>
<% end %>
<%= numbered_paginator(@posts) %> <%= numbered_paginator(@posts) %>
</div> </div>