From e45c2ce560b10c94c351ef3c7f9bd01848e6e97b Mon Sep 17 00:00:00 2001 From: zmagod Date: Thu, 8 Jun 2017 13:41:27 +0200 Subject: [PATCH] fixes bug with smart annotations in reports [fixes SCI-1328] --- app/helpers/application_helper.rb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 95e991dff..3bdf26bb1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -229,11 +229,25 @@ module ApplicationHelper raw(user_description) + raw('" >') + user_name + raw('') 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