From: Tom Hughes Date: Thu, 17 Oct 2019 11:16:28 +0000 (+0100) Subject: Allow administrators to see deleted diary comments X-Git-Tag: live~3320 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/936967d0cbf389431c7a6ba79c169a285140477d?ds=inline Allow administrators to see deleted diary comments --- diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index d4a32efb2..ba2a2976e 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -235,11 +235,12 @@ class DiaryEntriesController < ApplicationController end def comments + conditions = { :user_id => @user } + + conditions[:visible] = true unless current_user&.administrator? + @comment_pages, @comments = paginate(:diary_comments, - :conditions => { - :user_id => @user, - :visible => true - }, + :conditions => conditions, :order => "created_at DESC", :per_page => 20) @page = (params[:page] || 1).to_i diff --git a/app/views/diary_entries/comments.html.erb b/app/views/diary_entries/comments.html.erb index 10028bdea..56dba30b8 100644 --- a/app/views/diary_entries/comments.html.erb +++ b/app/views/diary_entries/comments.html.erb @@ -10,7 +10,7 @@ <% @comments.each do |comment| -%> <% cl = cycle("table0", "table1") %> - + "> <%= link_to comment.diary_entry.title, diary_entry_path(comment.diary_entry.user, comment.diary_entry) %> <%= time_ago_in_words(comment.created_at, :scope => :'datetime.distance_in_words_ago') %> <%= comment.body.to_html %>