2019-03-25 10:53:45 +01:00
|
|
|
module Users
|
2018-11-01 13:00:35 +01:00
|
|
|
class CommencerController < ApplicationController
|
2019-01-16 11:57:58 +01:00
|
|
|
layout 'procedure_context'
|
|
|
|
|
|
|
|
def commencer
|
2019-07-05 10:37:29 +02:00
|
|
|
@procedure = retrieve_procedure
|
|
|
|
return procedure_not_found if @procedure.blank? || @procedure.brouillon?
|
2019-01-16 11:57:58 +01:00
|
|
|
|
|
|
|
render 'commencer/show'
|
2018-11-01 13:00:35 +01:00
|
|
|
end
|
|
|
|
|
2019-01-16 11:57:58 +01:00
|
|
|
def commencer_test
|
2019-07-05 10:37:29 +02:00
|
|
|
@procedure = retrieve_procedure
|
|
|
|
return procedure_not_found if @procedure.blank? || @procedure.publiee?
|
2019-01-16 11:57:58 +01:00
|
|
|
|
|
|
|
render 'commencer/show'
|
|
|
|
end
|
|
|
|
|
2020-02-27 17:39:11 +01:00
|
|
|
def dossier_vide_pdf
|
|
|
|
@procedure = retrieve_procedure
|
|
|
|
return procedure_not_found if @procedure.blank? || @procedure.brouillon?
|
|
|
|
|
2020-03-17 14:51:27 +01:00
|
|
|
generate_empty_pdf(@procedure)
|
2020-02-27 17:39:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def dossier_vide_pdf_test
|
|
|
|
@procedure = retrieve_procedure
|
|
|
|
return procedure_not_found if @procedure.blank? || @procedure.publiee?
|
|
|
|
|
2020-03-17 14:51:27 +01:00
|
|
|
generate_empty_pdf(@procedure)
|
2020-02-27 17:39:11 +01:00
|
|
|
end
|
|
|
|
|
2019-01-16 11:57:58 +01:00
|
|
|
def sign_in
|
2019-07-05 10:37:29 +02:00
|
|
|
@procedure = retrieve_procedure
|
2019-04-04 14:03:03 +02:00
|
|
|
return procedure_not_found if @procedure.blank?
|
|
|
|
|
|
|
|
store_user_location!(@procedure)
|
2019-01-16 11:57:58 +01:00
|
|
|
redirect_to new_user_session_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def sign_up
|
2019-07-05 10:37:29 +02:00
|
|
|
@procedure = retrieve_procedure
|
2019-04-04 14:03:03 +02:00
|
|
|
return procedure_not_found if @procedure.blank?
|
|
|
|
|
|
|
|
store_user_location!(@procedure)
|
2019-01-16 11:57:58 +01:00
|
|
|
redirect_to new_user_registration_path
|
|
|
|
end
|
|
|
|
|
2019-04-02 15:03:35 +02:00
|
|
|
def france_connect
|
2019-07-05 10:37:29 +02:00
|
|
|
@procedure = retrieve_procedure
|
2019-04-04 14:03:03 +02:00
|
|
|
return procedure_not_found if @procedure.blank?
|
|
|
|
|
|
|
|
store_user_location!(@procedure)
|
2019-04-02 15:03:35 +02:00
|
|
|
redirect_to france_connect_particulier_path
|
|
|
|
end
|
|
|
|
|
2019-03-28 11:14:01 +01:00
|
|
|
def procedure_for_help
|
2019-07-05 10:37:29 +02:00
|
|
|
retrieve_procedure
|
2019-03-28 11:14:01 +01:00
|
|
|
end
|
|
|
|
|
2019-01-16 11:57:58 +01:00
|
|
|
private
|
|
|
|
|
2019-07-05 10:37:29 +02:00
|
|
|
def retrieve_procedure
|
|
|
|
Procedure.publiees.or(Procedure.brouillons).find_by(path: params[:path])
|
|
|
|
end
|
|
|
|
|
2019-04-04 14:03:03 +02:00
|
|
|
def procedure_not_found
|
2019-01-16 11:57:58 +01:00
|
|
|
procedure = Procedure.find_by(path: params[:path])
|
2019-04-04 14:03:03 +02:00
|
|
|
|
2019-11-14 09:43:45 +01:00
|
|
|
if procedure&.close?
|
2019-04-04 14:03:03 +02:00
|
|
|
flash.alert = t('errors.messages.procedure_archived')
|
|
|
|
else
|
|
|
|
flash.alert = t('errors.messages.procedure_not_found')
|
|
|
|
end
|
|
|
|
|
2019-07-05 10:37:29 +02:00
|
|
|
redirect_to root_path
|
2019-04-04 14:03:03 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def store_user_location!(procedure)
|
2019-03-27 17:46:35 +01:00
|
|
|
store_location_for(:user, helpers.procedure_lien(procedure))
|
2018-11-01 13:00:35 +01:00
|
|
|
end
|
2020-03-17 14:51:27 +01:00
|
|
|
|
|
|
|
def generate_empty_pdf(procedure)
|
|
|
|
@dossier = procedure.new_dossier
|
|
|
|
s = render_to_string(file: 'dossiers/dossier_vide', formats: [:pdf])
|
|
|
|
send_data(s, :filename => "#{procedure.libelle}.pdf")
|
|
|
|
end
|
2018-11-01 13:00:35 +01:00
|
|
|
end
|
|
|
|
end
|