2024-05-17 09:09:32 -04:00
|
|
|
class ImportsController < ApplicationController
|
2024-10-01 10:47:59 -04:00
|
|
|
before_action :set_import, only: %i[show publish destroy]
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
def publish
|
|
|
|
@import.publish_later
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
redirect_to import_path(@import), notice: "Your import has started in the background."
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
def index
|
|
|
|
@imports = Current.family.imports
|
2024-07-16 15:23:45 +02:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
render layout: with_sidebar
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
def new
|
|
|
|
@pending_import = Current.family.imports.ordered.pending.first
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
def create
|
|
|
|
import = Current.family.imports.create! import_params
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
redirect_to import_upload_path(import)
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
def show
|
|
|
|
redirect_to import_confirm_path(@import), alert: "Please finalize your mappings before proceeding." unless @import.publishable?
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
def destroy
|
|
|
|
@import.destroy
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
redirect_to imports_path, notice: "Your import has been deleted."
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def set_import
|
|
|
|
@import = Current.family.imports.find(params[:id])
|
|
|
|
end
|
|
|
|
|
2024-10-01 10:47:59 -04:00
|
|
|
def import_params
|
|
|
|
params.require(:import).permit(:type)
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
|
|
|
end
|