[openstreetmap/openstreetmap-website] Adds optional use of notes records (PR #5511)

Nenad Vujicic notifications at github.com
Thu Jan 23 16:23:58 UTC 2025


@nenad-vujicic commented on this pull request.



>    def description
-    comments.first.body
+    if !author.nil? && author.status == "deleted"
+      RichText.new("text", I18n.t("notes.show.description_when_author_is_deleted"))
+    elsif user_ip.nil? && user_id.nil?
+      comments.first.body
+    else
+      RichText.new("text", self[:description])
+    end
   end
 
-  # Return the note's author object, derived from the first comment
+  # Return the note's author object, unless record is unavailable and
+  # it will be derived from the first comment
   def author
-    comments.first.author
-  end
-
-  # Return the note's author ID, derived from the first comment
-  def author_id
-    comments.first.author_id
-  end
-
-  # Return the note's author IP address, derived from the first comment
-  def author_ip
-    comments.first.author_ip
+    if user_ip.nil? && user_id.nil?
+      all_comments.first.author
+    else
+      self[:author]
+    end
   end

This opens 2 problems with notes with deleted users:

- When we click on such note, it will show "deleted" as a description, but first next comment will be lost (i.e. we need to update app/views/notes/show.html.erb not to drop first comment if author is deleted) and
- When we hover over such note, it will show first "note.comments" comment instead of "deleted".

Should we fix these in this PR or in next?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5511#discussion_r1927277396
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5511/review/2570378389 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250123/a6c72746/attachment.htm>


More information about the rails-dev mailing list