2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-10-01 12:41:57 +02:00
|
|
|
class API::V2::DossiersController < API::V2::BaseController
|
|
|
|
before_action :ensure_dossier_present
|
2024-07-22 11:05:58 +02:00
|
|
|
skip_before_action :authenticate_from_token
|
2024-07-22 11:11:06 +02:00
|
|
|
skip_before_action :allow_only_persisted_queries
|
2020-10-01 12:41:57 +02:00
|
|
|
|
|
|
|
def pdf
|
2024-03-08 17:14:21 +01:00
|
|
|
@acls = PiecesJustificativesService.new(user_profile: Administrateur.new, export_template: nil).acl_for_dossier_export(dossier.procedure)
|
2021-02-17 19:02:31 +01:00
|
|
|
render(template: 'dossiers/show', formats: [:pdf])
|
2020-10-01 12:41:57 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def geojson
|
|
|
|
send_data dossier.to_feature_collection.to_json,
|
|
|
|
type: 'application/json',
|
|
|
|
filename: "dossier-#{dossier.id}-features.json"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2023-11-08 12:19:03 +01:00
|
|
|
def request_logs(logs)
|
2023-04-19 18:00:08 +02:00
|
|
|
super
|
|
|
|
if dossier.present?
|
2023-11-08 12:19:03 +01:00
|
|
|
logs.merge!(ds_dossier_id: dossier.id.to_s, ds_procedure_id: dossier.procedure.id.to_s)
|
2023-04-19 18:00:08 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-01 12:41:57 +02:00
|
|
|
def ensure_dossier_present
|
|
|
|
if dossier.blank?
|
|
|
|
head :unauthorized
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def dossier
|
|
|
|
@dossier ||= GlobalID::Locator.locate_signed(params[:id].to_s, for: 'api_v2')
|
|
|
|
end
|
|
|
|
end
|