Class: BulkSubmissionExcel::DownloadsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BulkSubmissionExcel::DownloadsController
- Defined in:
- app/controllers/bulk_submission_excel/downloads_controller.rb
Overview
Generate a bulk submission excel template from basic user provided data
Constant Summary
Constants included from FlashTruncation
FlashTruncation::STRING_OVERHEAD
Instance Method Summary collapse
Methods inherited from ApplicationController
#block_api_access, #clean_params_from_check, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!
Methods included from FlashTruncation
#max_flash_size, #truncate_flash, #truncate_flash_array
Instance Method Details
#create ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/bulk_submission_excel/downloads_controller.rb', line 6 def create finder = Asset::Finder.new(submission_parameters.fetch(:asset_barcodes, '').split(/\s+/)) download = BulkSubmissionExcel::Download.new( column_list: BulkSubmissionExcel.configuration.columns.all, range_list: BulkSubmissionExcel.configuration.ranges, defaults: params[:defaults], assets: finder.resolve ) file = Tempfile.new download.save(file) send_file file.path, content_type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', filename: "#{finder..join('_')}_#{Time.current.strftime('%Y%m%d')}.xlsx" rescue Asset::Finder::InvalidInputException => e flash[:error] = e. redirect_back fallback_location: bulk_submissions_path ensure file&.close end |
#new ⇒ Object
24 25 26 27 28 29 |
# File 'app/controllers/bulk_submission_excel/downloads_controller.rb', line 24 def new @submission_template = SubmissionTemplate.find_by(id: params[:submission_template_id]) @input_field_infos = @submission_template&.input_field_infos || [] @input_field_infos.reject! { |k| k.key == :customer_accepts_responsibility } render 'new', layout: !request.xhr? end |
#submission_parameters ⇒ Object
31 32 33 |
# File 'app/controllers/bulk_submission_excel/downloads_controller.rb', line 31 def submission_parameters params.require(:bulk_submission_excel_download).permit(:asset_barcodes) end |