2 class DataController < ApplicationController
5 before_action :authorize_web
6 before_action :set_locale
7 before_action :check_database_readable
9 authorize_resource :class => Trace
11 before_action :offline_redirect
14 trace = Trace.visible.find(params[:trace_id])
16 if trace.public? || (current_user && current_user == trace.user)
17 if Acl.no_trace_download(request.remote_ip)
19 elsif request.format == Mime[:xml]
20 send_data(trace.xml_file.read, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment")
21 elsif request.format == Mime[:gpx]
22 send_data(trace.xml_file.read, :filename => "#{trace.id}.gpx", :type => request.format.to_s, :disposition => "attachment")
23 elsif trace.file.attached?
24 redirect_to rails_blob_path(trace.file, :disposition => "attachment")
26 send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
31 rescue ActiveRecord::RecordNotFound
38 render :template => "traces/offline" if Settings.status == "gpx_offline"