demarches-normaliennes/app/controllers/new_administrateur/sources_particulier_controller.rb

33 lines
863 B
Ruby
Raw Normal View History

2021-09-13 15:59:58 +02:00
module NewAdministrateur
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