Apply anon display name settings to question author display
This commit is contained in:
parent
768d360ce7
commit
d1ad34eb9c
|
@ -26,7 +26,8 @@ module ApplicationHelper::TitleMethods
|
|||
end
|
||||
|
||||
def question_title(question)
|
||||
name = user_screen_name question.user, anonymous: question.author_is_anonymous, url: false
|
||||
context_user = question.answers&.first&.user if question.direct
|
||||
name = user_screen_name question.user, context_user: context_user, anonymous: question.author_is_anonymous, url: false
|
||||
generate_title name, "asked", question.content
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'cgi'
|
|||
module SocialHelper::TumblrMethods
|
||||
def tumblr_title(answer)
|
||||
asker = if answer.question.author_is_anonymous?
|
||||
APP_CONFIG['anonymous_name']
|
||||
answer.user.profile.anon_display_name.presence || APP_CONFIG['anonymous_name']
|
||||
else
|
||||
answer.question.user.profile.safe_name
|
||||
end
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
module UserHelper
|
||||
# Decides what user name to show.
|
||||
# @param context_user [User] the user whose the profile preferences should be applied
|
||||
# @return [String] The user name
|
||||
def user_screen_name(user, anonymous: false, url: true, link_only: false)
|
||||
return APP_CONFIG['anonymous_name'] if user.nil? || anonymous
|
||||
name = user.profile.display_name.blank? ? user.screen_name : user.profile.display_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
|
||||
|
||||
name = user.profile.display_name.presence || user.screen_name
|
||||
if url
|
||||
link = show_user_profile_path(user.screen_name)
|
||||
return link if link_only
|
||||
return link_to(name, link, class: "#{"user--banned" if user.banned?}")
|
||||
|
||||
return link_to(name, link, class: ("user--banned" if user.banned?).to_s)
|
||||
end
|
||||
name.strip
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
%i.fa.fa-gears
|
||||
View in Kontrollzentrum
|
||||
%h6.text-muted.media-heading.answerbox__question-user
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(a.question.user, anonymous: a.question.author_is_anonymous), time: time_tooltip(a.question))
|
||||
= raw t('views.answerbox.asked', user: user_screen_name(a.question.user, context_user: a.user, anonymous: a.question.author_is_anonymous), time: time_tooltip(a.question))
|
||||
- if !a.question.author_is_anonymous && !a.question.direct
|
||||
·
|
||||
%a{ href: show_user_question_path(a.question.user.screen_name, a.question.id) }
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
%img.answerbox__question-user-avatar.avatar-md{ src: i.question.user.profile_picture.url(:medium) }
|
||||
.media-body
|
||||
%h6.text-muted.media-heading.answerbox__question-user
|
||||
= t(".asked_html", user: user_screen_name(i.question.user, anonymous: i.question.author_is_anonymous), time: time_tooltip(i.question))
|
||||
= t(".asked_html", user: user_screen_name(i.question.user, context_user: i.user, anonymous: i.question.author_is_anonymous), time: time_tooltip(i.question))
|
||||
- if !i.question.author_is_anonymous && i.question.answer_count.positive?
|
||||
·
|
||||
%a{ href: show_user_question_path(i.question.user.screen_name, i.question.id) }
|
||||
|
|
Loading…
Reference in New Issue