REFACTOR: Add full_url and display_name to User

Lets stop writing the same code over and over again.
This commit is contained in:
Gerhard Schlager
2022-04-13 15:52:56 +02:00
committed by Gerhard Schlager
parent 650adbe423
commit b3cda195b8
8 changed files with 22 additions and 35 deletions

View File

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