Sha256: 9cc3ad872c846c2fc5cfac8f483c043db0dd5e1eec10bb1b89112eecdb084255

Contents?: true

Size: 964 Bytes

Versions: 24

Compression:

Stored size: 964 Bytes

Contents

module Workarea
  module Admin
    class DataFileImportsController < Admin::ApplicationController
      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)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
workarea-admin-3.4.45 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.44 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.43 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.42 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.41 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.40 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.39 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.38 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.37 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.36 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.35 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.34 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.33 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.32 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.31 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.30 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.29 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.28 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.27 app/controllers/workarea/admin/data_file_imports_controller.rb
workarea-admin-3.4.26 app/controllers/workarea/admin/data_file_imports_controller.rb