2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-11-25 16:26:55 +01:00
|
|
|
module Administrateurs
|
2021-09-13 15:59:58 +02:00
|
|
|
class SourcesParticulierController < AdministrateurController
|
|
|
|
before_action :retrieve_procedure
|
|
|
|
|
|
|
|
def show
|
|
|
|
@available_sources = sources_service.available_sources
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2021-09-17 12:22:01 +02:00
|
|
|
if @procedure.update(api_particulier_sources: sources_params)
|
|
|
|
redirect_to admin_procedure_api_particulier_sources_path(@procedure), notice: t('.sources_ok')
|
|
|
|
else
|
|
|
|
flash.now.alert = @procedure.errors.full_messages
|
|
|
|
render :show
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def sources_params
|
|
|
|
requested_sources = params
|
|
|
|
.with_defaults(api_particulier_sources: {})
|
|
|
|
.to_unsafe_hash[:api_particulier_sources]
|
|
|
|
|
|
|
|
sources_service.sanitize(requested_sources)
|
|
|
|
end
|
|
|
|
|
|
|
|
def sources_service
|
|
|
|
@sources_service ||= APIParticulier::Services::SourcesService.new(@procedure)
|
2021-09-13 15:59:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|