2024-09-25 14:36:26 +02:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class Procedure::ImportComponent < ApplicationComponent
|
|
|
|
|
def initialize(procedure:)
|
|
|
|
|
@procedure = procedure
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def scope
|
|
|
|
|
@procedure.routing_enabled? ? 'groupes' : 'instructeurs'
|
|
|
|
|
end
|
|
|
|
|
|
2024-10-14 14:52:44 +02:00
|
|
|
|
def template_file
|
2024-09-25 14:36:26 +02:00
|
|
|
|
if @procedure.routing_enabled?
|
|
|
|
|
'/csv/import-groupe-test.csv'
|
|
|
|
|
else
|
|
|
|
|
'/csv/import-instructeurs-test.csv'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def template_detail
|
|
|
|
|
"#{File.extname(csv_template.to_path).upcase.delete_prefix('.')} – #{number_to_human_size(csv_template.size)}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def csv_max_size
|
|
|
|
|
Administrateurs::GroupeInstructeursController::CSV_MAX_SIZE
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def csv_template
|
|
|
|
|
template_path.open
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def template_path
|
2024-10-14 14:52:44 +02:00
|
|
|
|
Rails.public_path.join(template_file.delete_prefix('/'))
|
2024-09-25 14:36:26 +02:00
|
|
|
|
end
|
|
|
|
|
end
|