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)
end
def undeleted
where("is_deleted = false")
end
def post_tags_match(query)
PostQueryBuilder.new(query).build(self.joins(:post)).reorder("")
end

View File

@@ -5,15 +5,17 @@
<div class="comments-for-post">
<div class="list-of-comments">
<% @comments.each do |comment| %>
<div id="post_<%= comment.post.id %>" class="post <%= PostPresenter.preview_class(comment.post) %>" <%= PostPresenter.data_attributes(comment.post) %>>
<div class="preview">
<% if comment.post.visible? %>
<%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %>
<% end %>
<% 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 class="preview">
<% if comment.post.visible? %>
<%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %>
<% end %>
</div>
<%= render :partial => "comments/partials/show/comment", :collection => [comment] %>
<div class="clearfix"></div>
</div>
<%= render :partial => "comments/partials/show/comment", :collection => [comment] %>
<div class="clearfix"></div>
</div>
<% end %>
<% end %>
</div>
</div>

View File

@@ -12,15 +12,17 @@
<% end %>
<% @posts.select {|x| x.visible?}.each do |post| %>
<div id="post_<%= post.id %>" class="post <%= PostPresenter.preview_class(post) %>" <%= PostPresenter.data_attributes(post) %>>
<div class="preview">
<% if post.visible? %>
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
<% end %>
<% if CurrentUser.is_moderator? || post.comments.undeleted.exists? %>
<div id="post_<%= post.id %>" class="post <%= PostPresenter.preview_class(post) %>" <%= PostPresenter.data_attributes(post) %>>
<div class="preview">
<% if post.visible? %>
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
<% end %>
</div>
<%= render "comments/partials/index/list", :post => post, :comments => post.comments.visible(CurrentUser.user).recent.reverse, :show_header => true %>
<div class="clearfix"></div>
</div>
<%= render "comments/partials/index/list", :post => post, :comments => post.comments.visible(CurrentUser.user).recent.reverse, :show_header => true %>
<div class="clearfix"></div>
</div>
<% end %>
<% end %>
<%= numbered_paginator(@posts) %>