External User: Set name to displayname and introduce real_name

This commit is contained in:
Sebastian Serth
2018-12-12 16:47:49 +01:00
parent 25602972ab
commit b4b9ab48d0
2 changed files with 23 additions and 7 deletions

View File

@ -4,12 +4,28 @@ class ExternalUser < ApplicationRecord
validates :consumer_id, presence: true
validates :external_id, presence: true
def displayname
result = name
if(result == nil || result == "")
result = "User " + id.to_s
end
result
def name
# Internal name, shown to teachers and administrators
pseudo_name
end
def displayname
# External name, shown to the user itself and other users, e.g. on RfCs
pseudo_name
end
def real_name
# Name attribute of the object as persistet in the database
self[:name]
end
def pseudo_name
if real_name.blank?
"User " + id.to_s
else
real_name
end
end
private :pseudo_name
end