mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
REFACTOR: Add full_url and display_name to User
Lets stop writing the same code over and over again.
This commit is contained in:
committed by
Gerhard Schlager
parent
650adbe423
commit
b3cda195b8
@@ -16,12 +16,6 @@ class TopicPoster < OpenStruct
|
||||
end
|
||||
|
||||
def name_and_description
|
||||
if SiteSetting.prioritize_username_in_ux? || user.name.blank?
|
||||
name = user.username
|
||||
else
|
||||
name = user.name
|
||||
end
|
||||
|
||||
I18n.t("js.user.avatar.name_and_description", name: name, description: description)
|
||||
I18n.t("js.user.avatar.name_and_description", name: user.display_name, description: description)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1461,6 +1461,18 @@ class User < ActiveRecord::Base
|
||||
username_lower == User.normalize_username(another_username)
|
||||
end
|
||||
|
||||
def full_url
|
||||
"#{Discourse.base_url}/u/#{encoded_username}"
|
||||
end
|
||||
|
||||
def display_name
|
||||
if SiteSetting.prioritize_username_in_ux?
|
||||
username
|
||||
else
|
||||
name.presence || username
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def badge_grant
|
||||
|
||||
Reference in New Issue
Block a user