@AntonKhorev 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
If `author` returns the true author, `description` should also return the true
description. There's `note_author` helper which hides the author when
necessary. Similarly you can make a helper that hides the description, and you
won't need `I18n.t("notes.show.description_when_author_is_deleted")` inside the
model. And you'll use the helper in these places:
https://github.com/openstreetmap/openstreetmap-website/pull/5494/commits/2c19c2143ec51e507d19b41fb6c89454b3d83dfc.
In #3607 I also [removed the deleted author](
https://github.com/openstreetmap/openstreetmap-website/pull/3607/files#diff-9b8b3e6d46a2a808a27e4c2f8d88c5470d39ee77146f8bb530124c0cacc35dbeR16)
from rss.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5511#pullrequestreview-2568828414
You are receiving this because you are subscribed to this thread.
Message ID:
<openstreetmap/openstreetmap-website/pull/5511/review/2568828...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev