Sha256: 189cc072b65267fffd4de01f74cccb1bf117ac507e92a488f653ff26535efaec

Contents?: true

Size: 1.08 KB

Versions: 27

Compression:

Stored size: 1.08 KB

Contents

module Workarea
  module Admin
    class DataFileImportsController < Admin::ApplicationController
      before_action :check_publishing_authorization
      before_action :set_import

      def new
      end

      def sample
        filename = "#{@import.name.downcase.underscore}.#{@import.file_type}"
        send_data @import.sample_file_content, filename: filename, type: @import.mime_type, disposition: :attachment
      end

      def create
        if @import.save
          flash[:success] = t('workarea.admin.data_file_imports.flash_messages.processing')
          redirect_to return_to.presence || root_path
        else
          render :new, status: :unprocessable_entity
        end
      end

      private

      def set_import
        @import = DataFile::Import.new(import_params)
      end

      def import_params
        base = params.select { |k, v| k.in?(DataFile::Import.fields.keys) }
        base.merge(params[:import] || {})
            .merge(
              created_by_id: current_user.id,
              release_id: params[:publishing]
            )
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.26 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.25 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.23 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.22 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.21 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.20 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.19 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.18 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.17 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.16 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.15 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.14 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.13 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.12 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.11 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.10 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.9 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.8 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.5.7 app/controllers/workarea/admin/data_file_imports_controller.rb