2017-03-31 02:42:33 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-21 15:13:37 +09:00
|
|
|
class Settings::ImportsController < Settings::BaseController
|
2019-07-23 17:30:24 +09:00
|
|
|
layout 'admin'
|
|
|
|
|
|
|
|
before_action :authenticate_user!
|
2017-03-31 02:42:33 +09:00
|
|
|
before_action :set_account
|
|
|
|
|
|
|
|
def show
|
|
|
|
@import = Import.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@import = Import.new(import_params)
|
|
|
|
@import.account = @account
|
|
|
|
|
|
|
|
if @import.save
|
|
|
|
ImportWorker.perform_async(@import.id)
|
|
|
|
redirect_to settings_import_path, notice: I18n.t('imports.success')
|
|
|
|
else
|
2017-04-19 22:37:42 +09:00
|
|
|
render :show
|
2017-03-31 02:42:33 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_account
|
|
|
|
@account = current_user.account
|
|
|
|
end
|
|
|
|
|
|
|
|
def import_params
|
|
|
|
params.require(:import).permit(:data, :type)
|
|
|
|
end
|
|
|
|
end
|