2019-04-30 00:43:34 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-21 16:15:11 +01:00
|
|
|
class ZipExportsController < ApplicationController
|
2019-04-30 00:43:34 +02:00
|
|
|
before_action :load_var, only: %i(download download_export_all_zip)
|
2019-08-01 13:17:24 +02:00
|
|
|
# File download permissions are now managed by ActiveStorage controllers
|
2017-03-21 16:15:11 +01:00
|
|
|
|
|
|
|
def download
|
2019-07-05 16:56:05 +02:00
|
|
|
if !@zip_export.zip_file.attached?
|
|
|
|
render_404
|
2017-03-23 15:45:02 +01:00
|
|
|
else
|
2019-07-05 16:56:05 +02:00
|
|
|
redirect_to rails_blob_path(@zip_export.zip_file, disposition: 'attachment')
|
2017-03-23 15:45:02 +01:00
|
|
|
end
|
2017-03-21 16:15:11 +01:00
|
|
|
end
|
|
|
|
|
2018-09-16 20:28:26 +02:00
|
|
|
def download_export_all_zip
|
|
|
|
download
|
|
|
|
end
|
|
|
|
|
2017-03-29 09:32:23 +02:00
|
|
|
def file_expired; end
|
2017-03-27 10:38:28 +02:00
|
|
|
|
2017-03-21 16:15:11 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
def load_var
|
2019-04-30 00:43:34 +02:00
|
|
|
@zip_export = current_user.zip_exports.find_by_id(params[:id])
|
2019-09-23 13:33:02 +02:00
|
|
|
redirect_to(file_expired_url, status: :moved_permanently) and return unless @zip_export&.zip_file&.attached?
|
2018-09-16 20:28:26 +02:00
|
|
|
end
|
2017-03-21 16:15:11 +01:00
|
|
|
end
|