From: Anton Khorev Date: Thu, 6 Feb 2025 15:15:58 +0000 (+0300) Subject: Merge branch 'pull/5609' X-Git-Tag: live~151 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/1e0377e6b38aac74a7da221d22b3248ec69b50d7?hp=066a3e6635cce5f04b8d7baa2471b73db807b046 Merge branch 'pull/5609' --- diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 4b4f3d651..574c9b8b7 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -40,6 +40,10 @@ class NotesController < ApplicationController @note = Note.visible.find(params[:id]) @note_comments = @note.comments end + + @note_includes_anonymous = @note.author.nil? || @note_comments.find { |comment| comment.author.nil? } + + @note_comments = @note_comments.drop(1) unless !@note.author.nil? && @note.author.status == "deleted" rescue ActiveRecord::RecordNotFound render :template => "browse/not_found", :status => :not_found end diff --git a/app/models/note.rb b/app/models/note.rb index d37b863e5..807ee9ec8 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -94,7 +94,7 @@ class Note < ApplicationRecord # Return the note's description, derived from the first comment def description if user_ip.nil? && user_id.nil? - comments.first.body + all_comments.first.body else RichText.new("text", super) end @@ -103,7 +103,7 @@ class Note < ApplicationRecord # Return the note's author object, derived from the first comment def author if user_ip.nil? && user_id.nil? - comments.first.author + all_comments.first.author else super end diff --git a/app/views/notes/show.html.erb b/app/views/notes/show.html.erb index 4f20cdd44..b65926b5f 100644 --- a/app/views/notes/show.html.erb +++ b/app/views/notes/show.html.erb @@ -22,7 +22,7 @@

- <% if @note_comments.find { |comment| comment.author.nil? } -%> + <% if @note_includes_anonymous -%>

<%= t ".anonymous_warning" %>

<% end -%> @@ -52,10 +52,10 @@ <% end %> - <% if @note_comments.length > 1 %> + <% if @note_comments.length > 0 %>