Appease the dog overlords

This commit is contained in:
Karina Kwiatek 2022-06-21 16:27:07 +02:00 committed by Karina Kwiatek
parent 0196a9ea10
commit 15052e203e
4 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddAnonDisplayNameToProfiles < ActiveRecord::Migration[6.1]
def change
add_column :profiles, :anon_display_name, :string