From b14d31a1a97e34727f264fc09e02d83d318bbad9 Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Mon, 8 Dec 2025 13:13:20 +0100 Subject: [PATCH] Add dedicated changeset comment method --- app/mailers/user_mailer.rb | 2 +- app/models/changeset.rb | 2 ++ app/views/browse/_common_details.html.erb | 6 +----- app/views/changeset_subscriptions/_heading.html.erb | 2 +- app/views/changesets/_changeset.html.erb | 2 +- app/views/changesets/index.atom.builder | 4 ++-- app/views/changesets/show.html.erb | 2 +- app/views/dashboards/_contact.html.erb | 2 +- 8 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index d54e69fca..0899becad 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -176,7 +176,7 @@ class UserMailer < ApplicationMailer @comment = comment.body @owner = recipient == comment.changeset.user @commenter = comment.author.display_name - @changeset_comment = comment.changeset.tags["comment"].presence + @changeset_comment = comment.changeset.comment @time = comment.created_at @changeset_author = comment.changeset.user.display_name @changeset_subscription_url = changeset_subscription_url(comment.changeset) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 0249ecfd0..1188ae60c 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -200,6 +200,8 @@ class Changeset < ApplicationRecord end end + def comment = tags["comment"].presence + ## # set the auto-close time to be one hour in the future unless # that would make it more than 24h long, in which case clip to diff --git a/app/views/browse/_common_details.html.erb b/app/views/browse/_common_details.html.erb index a3b04f569..db1b71fab 100644 --- a/app/views/browse/_common_details.html.erb +++ b/app/views/browse/_common_details.html.erb @@ -8,11 +8,7 @@
- <% if common_details.changeset.tags["comment"].present? %> - <%= linkify(common_details.changeset.tags["comment"]) %> - <% else %> - <%= t "browse.no_comment" %> - <% end %> + <%= linkify(common_details.changeset.comment || t("browse.no_comment")) %>
<%= link_to changeset, :class => "changeset_id link-body-emphasis stretched-link" do %> - <%= changeset.tags["comment"].to_s.presence || t("browse.no_comment") %> + <%= changeset.comment || t("browse.no_comment") %> <% end %>
diff --git a/app/views/changesets/index.atom.builder b/app/views/changesets/index.atom.builder index 139a6a6ea..d8708528e 100644 --- a/app/views/changesets/index.atom.builder +++ b/app/views/changesets/index.atom.builder @@ -24,8 +24,8 @@ atom_feed(:language => I18n.locale, :schema_date => 2009, :href => api_changeset_download_url(changeset, :only_path => false), :type => "application/osmChange+xml" - if !changeset.tags.empty? && changeset.tags.key?("comment") - entry.title t(".feed.title_comment", :id => changeset.id, :comment => changeset.tags["comment"]) + if changeset.comment.present? + entry.title t(".feed.title_comment", :id => changeset.id, :comment => changeset.comment) else entry.title t(".feed.title", :id => changeset.id) end diff --git a/app/views/changesets/show.html.erb b/app/views/changesets/show.html.erb index 81dcd24e6..b20b46c7c 100644 --- a/app/views/changesets/show.html.erb +++ b/app/views/changesets/show.html.erb @@ -4,7 +4,7 @@- <%= linkify(@changeset.tags["comment"].to_s.presence || t("browse.no_comment")) %> + <%= linkify(@changeset.comment || t("browse.no_comment")) %>
<%= tag.p :class => "details", :data => { :changeset => changeset_data(@changeset) } do %> <%= changeset_details(@changeset) %> diff --git a/app/views/dashboards/_contact.html.erb b/app/views/dashboards/_contact.html.erb index d7db8e24c..302e29f9d 100644 --- a/app/views/dashboards/_contact.html.erb +++ b/app/views/dashboards/_contact.html.erb @@ -24,7 +24,7 @@ <% changeset = contact.changesets.first %> <% if changeset %> <%= t(".latest_edit_html", :ago => friendly_date_ago(changeset.created_at)) %> - <% comment = changeset.tags["comment"].to_s == "" ? t("browse.no_comment") : changeset.tags["comment"] %> + <% comment = changeset.comment || t("browse.no_comment") %><%= link_to comment, changeset, :title => t(".view_changeset_details") %><% else %> <%= t ".no_edits" %> -- 2.39.5