avatar fix

This commit is contained in:
Harry Bomrah 2015-08-21 15:25:40 +08:00
parent 4b45f63eda
commit 3e8b1f1119
2 changed files with 13 additions and 2 deletions

View File

@ -112,11 +112,16 @@ class Admin::TicketsApiController < ApplicationController
r = {"query" => qu.query, "responses" => []}
r["responses"] = qu.ticket_query_responses.asc(:created_at).collect do |qr|
user = User.find(qr.response_by) rescue nil
if user.member_profile.avatar.nil? || user.member_profile.avatar.thumb.url == "thumb_person.png"
avatar = "http://" + request.host_with_port + "/assets/thumb_person.png"
else
avatar = "http://" + request.host_with_port + user.member_profile.avatar.thumb.url
end
{
"response" => qr.response,
"response_time" => qr.created_at,
"response_by" => (user.name if !user.nil?),
"avatar" => ("http://" + request.host_with_port + user.member_profile.avatar.thumb.url if !user.member_profile.avatar.nil?)
"avatar" => avatar
}
end
response["ticket"]["queries"] << r

View File

@ -2,7 +2,13 @@
<div class="ticket-response-meta">
<div class="ticket-response-author">
<% user = User.find(response.response_by) rescue nil %>
<img class="ticket-response-avatar" src="<%= user.member_profile.avatar.thumb.url if !user.member_profile.avatar.nil? %>" />
<% if user.member_profile.avatar.nil? || user.member_profile.avatar.thumb.url == "thumb_person.png"
avatar = "/assets/thumb_person.png"
else
avatar = user.member_profile.avatar.thumb.url
end
%>
<img class="ticket-response-avatar" src="<%= avatar %>" />
<span class="ticket-response-name"><%= user.name if !user.nil? %></span>
</div>
<div class="ticket-response-created-date">