Replace usage of name in favor of displayname

This commit is contained in:
Sebastian Serth
2018-12-13 13:11:32 +01:00
parent b4b9ab48d0
commit 88081bb541
9 changed files with 13 additions and 30 deletions

View File

@ -4,28 +4,11 @@ class ExternalUser < ApplicationRecord
validates :consumer_id, presence: true
validates :external_id, presence: true
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?
if name.blank?
"User " + id.to_s
else
real_name
name
end
end
private :pseudo_name
end

View File

@ -3,6 +3,6 @@ h1 = t('.title', application_name: application_name)
- if current_user.try(:external_user?)
p = t('.text_signed_in_as_external_user', application_name: application_name)
- elsif current_user.try(:internal_user?)
p = t('.text_signed_in_as_internal_user', user_name: current_user.name)
p = t('.text_signed_in_as_internal_user', user_name: current_user.displayname)
- else
p == t('.text_signed_out', application_name: application_name, sign_in_path: sign_in_path)

View File

@ -3,7 +3,7 @@ h1
= render('shared/edit_button', object: @exercise_collection)
= row(label: 'exercise_collections.name', value: @exercise_collection.name)
= row(label: 'exercise_collections.user', value: link_to(@exercise_collection.user.name, @exercise_collection.user)) unless @exercise_collection.user.nil?
= row(label: 'exercise_collections.user', value: link_to(@exercise_collection.user.displayname, @exercise_collection.user)) unless @exercise_collection.user.nil?
= row(label: 'exercise_collections.use_anomaly_detection', value: @exercise_collection.use_anomaly_detection)
= row(label: 'exercise_collections.updated_at', value: @exercise_collection.updated_at)
@ -24,5 +24,5 @@ h4.mt-4 = t('activerecord.attributes.exercise_collections.exercises')
td = exercise_collection_item.position
td = link_to(exercise.title, exercise)
td = link_to_if(exercise.execution_environment && policy(exercise.execution_environment).show?, exercise.execution_environment, exercise.execution_environment)
td = link_to_if(exercise.user && policy(exercise.user).show?, exercise.user.name, exercise.user)
td = link_to_if(exercise.user && policy(exercise.user).show?, exercise.user.displayname, exercise.user)
td = link_to(t('shared.statistics'), statistics_exercise_path(exercise), 'data-turbolinks' => "false")

View File

@ -13,7 +13,7 @@ h1 = link_to(@exercise, exercise_path(@exercise))
li.card.mt-2
.card-header role="tab" id="heading"
div.clearfix.feedback-header
span.username = link_to(feedback.user.name, statistics_external_user_exercise_path(id: @exercise.id, external_user_id: feedback.user.id))
span.username = link_to(feedback.user.displayname, statistics_external_user_exercise_path(id: @exercise.id, external_user_id: feedback.user.id))
- if feedback.anomaly_notification
i class="fa fa-envelope-o" data-placement="top" data-toggle="tooltip" data-container="body" title=feedback.anomaly_notification.reason
span.date = feedback.created_at

View File

@ -10,7 +10,7 @@ h1 = ExternalUser.model_name.human(count: 2)
tbody
- @users.each do |user|
tr
td = user.name
td = user.displayname
td = link_to(user.consumer, user.consumer)
td = link_to(t('shared.show'), user)

View File

@ -1,6 +1,6 @@
h1 = @user.name
h1 = @user.displayname
= row(label: 'external_user.name', value: @user.real_name)
= row(label: 'external_user.name', value: @user.name)
//= row(label: 'external_user.email', value: @user.email)
= row(label: 'external_user.consumer', value: link_to(@user.consumer, @user.consumer))

View File

@ -19,7 +19,7 @@ h1 = UserExerciseFeedback.model_name.human(count: 2)
- @uefs.each do |uef|
tr
td = uef.user.id
td = uef.user.name
td = uef.user.displayname
td = link_to(uef.exercise.title, uef.exercise)
td = link_to(t('shared.show'), uef)
td = link_to(t('shared.destroy'), uef, data: {confirm: t('shared.confirm_destroy')}, method: :delete)

View File

@ -1 +1 @@
== t('mailers.user_mailer.send_thank_you_note.body', receiver_displayname: @receiver_displayname, link_to_comment: link_to(@rfc_link, @rfc_link), author: @author, thank_you_note: @thank_you_note )
== t('mailers.user_mailer.send_thank_you_note.body', receiver_displayname: @receiver_displayname, link_to_comment: link_to(@rfc_link, @rfc_link), author: @author.displayname, thank_you_note: @thank_you_note )

View File

@ -38,8 +38,8 @@ describe 'Authentication' do
visit(root_path)
end
it "displays the user's name" do
expect(page).to have_content(user.name)
it "displays the user's displayname" do
expect(page).to have_content(user.displayname)
end
it 'displays a sign out link' do