From a72709b6da6d2039ad7f6fb8d8dcdf5ff1b450c1 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Thu, 10 Nov 2016 17:26:00 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20bug=20Cerfa=20on=20=C2=AB=C2=A0Modifier?= =?UTF-8?q?=20document=C2=A0=C2=BB=20recap=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/description_controller.rb | 36 +++++++++++++------ config/locales/fr.yml | 4 +-- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index a8a08fc09..b74671a45 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -38,6 +38,15 @@ class Users::DescriptionController < UsersController return render 'show' end + unless params[:champs].nil? + champs_service_errors = ChampsService.save_formulaire @dossier.champs, params, mandatory + + unless champs_service_errors.empty? + flash.now.alert = (champs_service_errors.inject('') { |acc, error| acc+= error[:message]+'
' }).html_safe + return render 'show' + end + end + if @procedure.cerfa_flag? unless params[:cerfa_pdf].nil? cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user) @@ -48,15 +57,6 @@ class Users::DescriptionController < UsersController end end - unless params[:champs].nil? - champs_service_errors = ChampsService.save_formulaire @dossier.champs, params, mandatory - - unless champs_service_errors.empty? - flash.now.alert = (champs_service_errors.inject('') { |acc, error| acc+= error[:message]+'
' }).html_safe - return render 'show' - end - end - unless (errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).empty? flash.alert = errors_upload.html_safe return render 'show' @@ -82,10 +82,24 @@ class Users::DescriptionController < UsersController @dossier ||= Dossier.find(params[:dossier_id]) if invite @dossier ||= current_user_dossier + if @dossier.procedure.cerfa_flag? + unless params[:cerfa_pdf].nil? + cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user) + unless cerfa.save + flash.alert = cerfa.errors.full_messages.join('
').html_safe + end + end + end + if !((errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).empty?) - flash.alert = errors_upload.html_safe + if flash.alert.nil? + flash.alert = errors_upload.html_safe + else + flash.alert = (flash.alert + '
' + errors_upload.html_safe).html_safe + end + else - flash.notice = 'Nouveaux fichiers envoyés' + flash.notice = 'Nouveaux fichiers envoyés' if flash.alert.nil? @dossier.next_step! 'user', 'update' end diff --git a/config/locales/fr.yml b/config/locales/fr.yml index afe725ff8..bb400f609 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -44,11 +44,11 @@ fr: piece_justificative: attributes: content: - size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 3Mo." + size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 6Mo." cerfa: attributes: content: - size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 3Mo." + size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 6Mo." user: attributes: reset_password_token: