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

View File

@ -4,11 +4,11 @@
<%= InternalUser.find(@request_for_comment.requestorid) %> | <%= @request_for_comment.requested_at %>
</p>
</div>
<!--
-->
<div id='commentitor' class='editor' data-read-only='true' data-file-id='<%=@request_for_comment.fileid%>'>
<%= CodeOcean::File.find(@request_for_comment.fileid).content %>
<!--
do not put a carriage return in the line below. it will be present in the presentation of the source code, otherwise.
-->
<div id='commentitor' class='editor' data-read-only='true' data-file-id='<%=@request_for_comment.fileid%>'><%= CodeOcean::File.find(@request_for_comment.fileid).content %>
</div>
<script type="text/javascript">