From 512e90ebd7c4c1f40de12329aa0c0ccda7d853db Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Tue, 18 Aug 2015 16:32:56 +0200 Subject: [PATCH] Show correct usernames on comments, have correct linenumbers on request_for_comments --- app/controllers/comments_controller.rb | 12 +++++++++++- app/views/request_for_comments/show.html.erb | 8 ++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 4da2bf5c..91e31068 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -40,7 +40,17 @@ class CommentsController < ApplicationController #@comments = Comment.where(file_id: params[:file_id]) #add names to comments - @comments.map{|comment| comment.username = Xikolo::UserClient.get(comment.user_id.to_s)[:display_name]} + # if the user is internal, set the name + # todo: + # if the user is external, fetch the displayname from xikolo + @comments.map{|comment| + if(comment.user_type == 'InternalUser') + comment.username = InternalUser.find(comment.user_id).name + elsif(comment.user_type == 'ExternalUser') + comment.username = ExternalUser.find(comment.user_id).name + #alternativ: Xikolo::UserClient.get(comment.user_id.to_s)[:display_name] + end + } else @comments = Comment.all.limit(0) #we need an empty relation here end diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb index d9779583..1b8e7495 100644 --- a/app/views/request_for_comments/show.html.erb +++ b/app/views/request_for_comments/show.html.erb @@ -4,11 +4,11 @@ <%= InternalUser.find(@request_for_comment.requestorid) %> | <%= @request_for_comment.requested_at %>

- -
- <%= CodeOcean::File.find(@request_for_comment.fileid).content %> + +
<%= CodeOcean::File.find(@request_for_comment.fileid).content %>