Merge pull request #663 from ZmagoD/zd_SCI_1328

fixes bug with smart annotations in reports [fixes SCI-1328]
This commit is contained in:
Zmago Devetak 2017-06-13 08:57:09 +02:00 committed by GitHub
commit 6cdf37041f

View file

@ -233,11 +233,25 @@ module ApplicationHelper
raw(user_description) + raw('" >') + user_name + raw('</a>')
end
# Dirty, dirty hack for displaying images in reports
def user_avatar_absolute_url(user, style)
unless user.avatar(style) == '/images/icon_small/missing.png'
return user.avatar(style)
prefix = ''
if ENV['PAPERCLIP_STORAGE'].present? &&
ENV['MAIL_SERVER_URL'].present? &&
ENV['PAPERCLIP_STORAGE'] != 'filesystem'
prefix = ENV['MAIL_SERVER_URL']
end
URI.join(Rails.application.routes.url_helpers.root_url,
"/images/#{style}/missing.png").to_s
# for development
prefix = 'localhost:3000' if ENV['MAIL_SERVER_URL'] == 'localhost'
if !prefix.empty? &&
!prefix.include?('http://') &&
!prefix.include?('https://')
prefix = request.ssl? ? "https://#{prefix}" : "http://#{prefix}"
end
unless user.avatar(style) == '/images/icon_small/missing.png'
return user.avatar(style, timeout: Constants::URL_LONG_EXPIRE_TIME)
end
url_for(prefix + "/images/#{style}/missing.png")
end
end