From 747b279f60055c77bca772df5d3ea5027c15b22f Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 21 Aug 2013 15:00:22 +0400 Subject: [PATCH] #267: fixed link to logs --- .../platforms/product_build_lists_controller.rb | 2 ++ app/controllers/projects/build_lists_controller.rb | 2 ++ app/helpers/builds_helper.rb | 10 ++++++++++ .../platforms/product_build_lists/show.json.jbuilder | 2 +- app/views/projects/build_lists/show.json.jbuilder | 2 +- 5 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 app/helpers/builds_helper.rb diff --git a/app/controllers/platforms/product_build_lists_controller.rb b/app/controllers/platforms/product_build_lists_controller.rb index 05f19331c..b35ad3396 100644 --- a/app/controllers/platforms/product_build_lists_controller.rb +++ b/app/controllers/platforms/product_build_lists_controller.rb @@ -1,5 +1,7 @@ # -*- encoding : utf-8 -*- class Platforms::ProductBuildListsController < Platforms::BaseController + include BuildsHelper + before_filter :authenticate_user! skip_before_filter :authenticate_user!, :only => [:index, :show, :log] if APP_CONFIG['anonymous_access'] before_filter :redirect_to_full_path_if_short_url, :only => :show diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index f491f8b1c..2fddaa1a0 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -1,5 +1,7 @@ # -*- encoding : utf-8 -*- class Projects::BuildListsController < Projects::BaseController + include BuildsHelper + NESTED_ACTIONS = [:index, :new, :create] before_filter :authenticate_user! diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb new file mode 100644 index 000000000..7883af12e --- /dev/null +++ b/app/helpers/builds_helper.rb @@ -0,0 +1,10 @@ +# -*- encoding : utf-8 -*- +module BuildsHelper + + def file_store_results_url(sha1, file_name) + url = "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{sha1}" + url << '.log?show=true' if file_name =~ /.*\.(log|txt)$/ + url + end + +end diff --git a/app/views/platforms/product_build_lists/show.json.jbuilder b/app/views/platforms/product_build_lists/show.json.jbuilder index bec226aac..543fb0dce 100644 --- a/app/views/platforms/product_build_lists/show.json.jbuilder +++ b/app/views/platforms/product_build_lists/show.json.jbuilder @@ -8,7 +8,7 @@ json.product_build_list do json.file_name result['file_name'] json.sha1 result['sha1'] json.size result['size'] - json.url "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{result['sha1']}" + json.url file_store_results_url(result['sha1'], result['file_name']) end if @product_build_list.results.present? end diff --git a/app/views/projects/build_lists/show.json.jbuilder b/app/views/projects/build_lists/show.json.jbuilder index c129e45c3..ede8d5cf3 100644 --- a/app/views/projects/build_lists/show.json.jbuilder +++ b/app/views/projects/build_lists/show.json.jbuilder @@ -34,7 +34,7 @@ json.build_list do json.file_name result['file_name'] json.sha1 result['sha1'] json.size result['size'] - json.url "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{result['sha1']}" + json.url file_store_results_url(result['sha1'], result['file_name']) end if @build_list.new_core? && @build_list.results.present? json.packages @build_list.packages do |package|