fetch usernames via xikolo api

This commit is contained in:
Ralf Teusner
2016-05-04 14:48:30 +02:00
parent 3f517dca01
commit 16c5191669
2 changed files with 9 additions and 5 deletions

View File

@ -34,8 +34,7 @@ class Xikolo::Client
end
def self.url
#todo: JanR: set an environment variable here, fallback value: http://open.hpi.de/api/
'http://localhost:2000/api/'
@url ||= Config.new(:code_ocean).read.fetch(:xikolo_api_url, 'http://localhost:3000/api/') #caches this with ||=, second value of fetch is default value
end
def self.accept
@ -43,7 +42,7 @@ class Xikolo::Client
end
def self.token
'Token token="'+Rails.application.config.xikolo[:token]+'"'
'Token token="'+Rails.application.secrets.openhpi_api_token+'"'
end
private

View File

@ -4,9 +4,14 @@ class Xikolo::UserClient
# return default values if user is not found or if there is a server issue:
if user
return {display_name: user['first_name'], user_visual: user['user_visual'], language: user['language']}
if user['display_name'].present?
name = user['display_name']
else
name = user['first_name']
end
return {display_name: name, user_visual: user['user_visual'], language: user['language']}
else
return {display_name: "Name" + user_id, user_visual: ActionController::Base.helpers.image_path('default.png'), language: "DE"}
return {display_name: "User" + user_id, user_visual: ActionController::Base.helpers.image_path('default.png'), language: "DE"}
end
end
end