Show correct usernames on comments, have correct linenumbers on request_for_comments

This commit is contained in:
Ralf Teusner
2015-08-18 16:32:56 +02:00
parent aa64d0be43
commit 512e90ebd7
2 changed files with 15 additions and 5 deletions

View File

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