Files
fizzy/app/controllers/imports_controller.rb
T
Stanko K.R. eed2b3c8a7 Cleanup code
2026-02-02 12:36:48 +01:00

39 lines
839 B
Ruby

class ImportsController < ApplicationController
layout "public"
disallow_account_scope only: %i[ new create ]
before_action :set_import, only: %i[ show ]
def new
end
def create
signup = Signup.new(identity: Current.identity, full_name: "Import", skip_account_seeding: true)
if signup.complete
start_import(signup.account)
else
render :new, alert: "Couldn't create account."
end
end
def show
end
private
def set_import
@import = Current.account.imports.find(params[:id])
end
def start_import(account)
import = nil
Current.set(account: account) do
import = account.imports.create!(identity: Current.identity, file: params[:file])
import.process_later
end
redirect_to import_path(import, script_name: account.slug)
end
end