From 0876ea0beece91be4cbd603e13951cfe6bc8e773 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 23 Jun 2021 20:09:19 +0100 Subject: [PATCH] Refactor terms declined flash message to use a partial This allows us to include a link in the flash message, without having to use html_safe. Also refactor to avoid having html angle brackets in the translation strings, while still allowing locale-specific urls. --- app/controllers/users_controller.rb | 2 +- app/views/users/_terms_declined_flash.html.erb | 1 + config/locales/en.yml | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 app/views/users/_terms_declined_flash.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 43933041c..00d427ac9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -42,7 +42,7 @@ class UsersController < ApplicationController if current_user current_user.terms_seen = true - flash[:notice] = t("users.new.terms declined", :url => t("users.new.terms declined url")).html_safe if current_user.save + flash[:notice] = { :partial => "users/terms_declined_flash" } if current_user.save if params[:referer] redirect_to safe_referer(params[:referer]) diff --git a/app/views/users/_terms_declined_flash.html.erb b/app/views/users/_terms_declined_flash.html.erb new file mode 100644 index 000000000..9c9d793db --- /dev/null +++ b/app/views/users/_terms_declined_flash.html.erb @@ -0,0 +1 @@ +<%= t ".terms_declined_html", :terms_declined_link => link_to(t(".terms_declined_link"), t(".terms_declined_url")) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index f6272c918..094a6e9c1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2334,8 +2334,6 @@ en: auth no password: "With third party authentication a password is not required, but some extra tools or server may still need one." continue: Sign Up terms accepted: "Thanks for accepting the new contributor terms!" - terms declined: "We are sorry that you have decided to not accept the new Contributor Terms. For more information, please see this wiki page." - terms declined url: https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined terms: title: "Terms" heading: "Terms" @@ -2358,6 +2356,10 @@ en: france: "France" italy: "Italy" rest_of_world: "Rest of the world" + terms_declined_flash: + terms_declined_html: We are sorry that you have decided to not accept the new Contributor Terms. For more information, please see %{terms_declined_link}. + terms_declined_link: this wiki page + terms_declined_url: https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined no_such_user: title: "No such user" heading: "The user %{user} does not exist" -- 2.39.5