This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-03-30 10:42:33 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-12-12 13:32:13 -08:00
|
|
|
class Settings::ImportsController < Settings::BaseController
|
2017-03-30 10:42:33 -07:00
|
|
|
layout 'admin'
|
|
|
|
|
|
|
|
before_action :authenticate_user!
|
|
|
|
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 06:37:42 -07:00
|
|
|
render :show
|
2017-03-30 10:42:33 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_account
|
|
|
|
@account = current_user.account
|
|
|
|
end
|
|
|
|
|
|
|
|
def import_params
|
2020-03-31 03:43:42 -07:00
|
|
|
params.require(:import).permit(:data, :type, :mode)
|
2017-03-30 10:42:33 -07:00
|
|
|
end
|
|
|
|
end
|