From 2def62ee19b2b7e6fa7ede5a486a7b12abf9529d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 5 Jul 2020 14:49:12 +0100 Subject: [PATCH] Fix errors with GPX offline mode --- app/controllers/api/traces_controller.rb | 6 +++--- app/controllers/traces_controller.rb | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/traces_controller.rb b/app/controllers/api/traces_controller.rb index 8979704a7..000bb7f90 100644 --- a/app/controllers/api/traces_controller.rb +++ b/app/controllers/api/traces_controller.rb @@ -12,7 +12,7 @@ module Api before_action :check_database_writable, :only => [:create, :update, :destroy] before_action :check_api_readable, :only => [:show, :data] before_action :check_api_writable, :only => [:create, :update, :destroy] - before_action :offline_redirect, :only => [:create, :destroy, :data] + before_action :offline_error, :only => [:create, :destroy, :data] around_action :api_call_handle_error def show @@ -158,8 +158,8 @@ module Api trace end - def offline_redirect - redirect_to :action => :offline if Settings.status == "gpx_offline" + def offline_error + report_error "GPX files offline for maintenance", :service_unavailable end end end diff --git a/app/controllers/traces_controller.rb b/app/controllers/traces_controller.rb index b800d305e..03487e7ab 100644 --- a/app/controllers/traces_controller.rb +++ b/app/controllers/traces_controller.rb @@ -90,6 +90,7 @@ class TracesController < ApplicationController end def new + logger.info "new" @title = t ".upload_trace" @trace = Trace.new(:visibility => default_visibility) end @@ -317,7 +318,8 @@ class TracesController < ApplicationController end def offline_redirect - redirect_to :action => :offline if Settings.status == "gpx_offline" + logger.info "offline_redirect status is #{Settings.status}" + render :action => :offline if Settings.status == "gpx_offline" end def default_visibility -- 2.39.5