DescriptionController: move instance var to local var

This commit is contained in:
Simon Lehericey 2017-04-10 12:29:14 +02:00
parent b36252b916
commit 157d1818b2

View file

@ -24,41 +24,41 @@ class Users::DescriptionController < UsersController
end end
def update def update
@dossier = current_user_dossier dossier = current_user_dossier
@procedure = @dossier.procedure procedure = dossier.procedure
return head :forbidden unless @dossier.can_be_initiated? return head :forbidden unless dossier.can_be_initiated?
@champs = @dossier.ordered_champs @champs = dossier.ordered_champs
check_mandatory_fields = !draft_submission? check_mandatory_fields = !draft_submission?
if params[:champs] if params[:champs]
champs_service_errors = ChampsService.save_champs @dossier.champs, champs_service_errors = ChampsService.save_champs dossier.champs,
params, params,
check_mandatory_fields check_mandatory_fields
return redirect_to_description_with_errors(@dossier, champs_service_errors) if champs_service_errors.any? return redirect_to_description_with_errors(dossier, champs_service_errors) if champs_service_errors.any?
end end
if @procedure.cerfa_flag? && params[:cerfa_pdf] if procedure.cerfa_flag? && params[:cerfa_pdf]
cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user) cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: dossier, user: current_user)
return redirect_to_description_with_errors(@dossier, cerfa.errors.full_messages) unless cerfa.save return redirect_to_description_with_errors(dossier, cerfa.errors.full_messages) unless cerfa.save
end end
errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params) errors_upload = PiecesJustificativesService.upload!(dossier, current_user, params)
return redirect_to_description_with_errors(@dossier, errors_upload) if errors_upload.any? return redirect_to_description_with_errors(dossier, errors_upload) if errors_upload.any?
if draft_submission? if draft_submission?
flash.notice = 'Votre brouillon a bien été sauvegardé.' flash.notice = 'Votre brouillon a bien été sauvegardé.'
redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon) redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon)
else else
if @dossier.draft? if dossier.draft?
@dossier.initiated! dossier.initiated!
NotificationMailer.send_notification(@dossier, @dossier.procedure.initiated_mail).deliver_now! NotificationMailer.send_notification(dossier, procedure.initiated_mail).deliver_now!
end end
flash.notice = 'Félicitations, votre demande a bien été enregistrée.' flash.notice = 'Félicitations, votre demande a bien été enregistrée.'
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id) redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: dossier.id)
end end
end end