From 15052e203e3d7bc130eef37a0e3ab3a32ee3190f Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 21 Jun 2022 16:27:07 +0200 Subject: [PATCH] Appease the dog overlords --- app/helpers/social_helper/tumblr_methods.rb | 2 +- app/helpers/user_helper.rb | 8 +++++++- app/views/settings/_profile.haml | 2 +- .../20220620193732_add_anon_display_name_to_profiles.rb | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/helpers/social_helper/tumblr_methods.rb b/app/helpers/social_helper/tumblr_methods.rb index 64987346..16fde405 100644 --- a/app/helpers/social_helper/tumblr_methods.rb +++ b/app/helpers/social_helper/tumblr_methods.rb @@ -3,7 +3,7 @@ require 'cgi' module SocialHelper::TumblrMethods def tumblr_title(answer) asker = if answer.question.author_is_anonymous? - answer.user.profile.anon_display_name.presence || APP_CONFIG['anonymous_name'] + answer.user.profile.anon_display_name.presence || APP_CONFIG["anonymous_name"] else answer.question.user.profile.safe_name end diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index 4a6b4cf7..e633679d 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -3,7 +3,7 @@ module UserHelper # @param context_user [User] the user whose the profile preferences should be applied # @return [String] The user name def user_screen_name(user, context_user: nil, anonymous: false, url: true, link_only: false) - return context_user&.profile&.anon_display_name.presence || APP_CONFIG['anonymous_name'] if user.nil? || anonymous + return anonymous_name(context_user) if user.nil? || anonymous name = user.profile.display_name.presence || user.screen_name if url @@ -14,4 +14,10 @@ module UserHelper end name.strip end + + private + + def anonymous_name(context_user) + context_user&.profile&.anon_display_name.presence || APP_CONFIG["anonymous_name"] + end end diff --git a/app/views/settings/_profile.haml b/app/views/settings/_profile.haml index ce715d75..0b7474d9 100644 --- a/app/views/settings/_profile.haml +++ b/app/views/settings/_profile.haml @@ -41,7 +41,7 @@ = f.text_field :motivation_header - = f.text_field :anon_display_name, placeholder: APP_CONFIG[:anonymous_name] + = f.text_field :anon_display_name, placeholder: APP_CONFIG["anonymous_name"] = f.text_field :website diff --git a/db/migrate/20220620193732_add_anon_display_name_to_profiles.rb b/db/migrate/20220620193732_add_anon_display_name_to_profiles.rb index 82a56f3e..15ecd6fb 100644 --- a/db/migrate/20220620193732_add_anon_display_name_to_profiles.rb +++ b/db/migrate/20220620193732_add_anon_display_name_to_profiles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddAnonDisplayNameToProfiles < ActiveRecord::Migration[6.1] def change add_column :profiles, :anon_display_name, :string