From 52c73efc284fafc117ebb8b47a68ea59dcc77a77 Mon Sep 17 00:00:00 2001 From: Toks Date: Thu, 23 Jul 2015 09:57:13 -0400 Subject: [PATCH] Fix thumbnail appearing next to deleted comments --- app/models/comment.rb | 4 ++++ app/views/comments/index_by_comment.html.erb | 18 ++++++++++-------- app/views/comments/index_by_post.html.erb | 18 ++++++++++-------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 1b0b08660..571adec26 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 diff --git a/app/views/comments/index_by_comment.html.erb b/app/views/comments/index_by_comment.html.erb index 752fa1cf4..fbe15cf40 100644 --- a/app/views/comments/index_by_comment.html.erb +++ b/app/views/comments/index_by_comment.html.erb @@ -5,15 +5,17 @@
<% @comments.each do |comment| %> -
> -
- <% 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? %> +
> +
+ <% if comment.post.visible? %> + <%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %> + <% end %> +
+ <%= render :partial => "comments/partials/show/comment", :collection => [comment] %> +
- <%= render :partial => "comments/partials/show/comment", :collection => [comment] %> -
-
+ <% end %> <% end %>
diff --git a/app/views/comments/index_by_post.html.erb b/app/views/comments/index_by_post.html.erb index 16ab979dd..939498c9c 100644 --- a/app/views/comments/index_by_post.html.erb +++ b/app/views/comments/index_by_post.html.erb @@ -12,15 +12,17 @@ <% end %> <% @posts.select {|x| x.visible?}.each do |post| %> -
> -
- <% if post.visible? %> - <%= link_to(image_tag(post.preview_file_url), post_path(post)) %> - <% end %> + <% if CurrentUser.is_moderator? || post.comments.undeleted.exists? %> +
> +
+ <% if post.visible? %> + <%= link_to(image_tag(post.preview_file_url), post_path(post)) %> + <% end %> +
+ <%= render "comments/partials/index/list", :post => post, :comments => post.comments.visible(CurrentUser.user).recent.reverse, :show_header => true %> +
- <%= render "comments/partials/index/list", :post => post, :comments => post.comments.visible(CurrentUser.user).recent.reverse, :show_header => true %> -
-
+ <% end %> <% end %> <%= numbered_paginator(@posts) %>