dossiers controller: render JSON if needed (#4545)

DossiersController : évite de générer du HTML en cas de requête JSON
This commit is contained in:
Pierre de La Morinerie 2019-11-20 13:02:18 +01:00 committed by GitHub
commit 5038df54df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -143,18 +143,19 @@ module Users
errors = update_dossier_and_compute_errors
if errors.present?
if passage_en_construction? && errors.blank?
@dossier.en_construction!
NotificationMailer.send_initiated_notification(@dossier).deliver_later
return redirect_to(merci_dossier_path(@dossier))
elsif errors.present?
flash.now.alert = errors
render :brouillon
else
if passage_en_construction?
@dossier.en_construction!
NotificationMailer.send_initiated_notification(@dossier).deliver_later
redirect_to merci_dossier_path(@dossier)
else
flash.now.notice = 'Votre brouillon a bien été sauvegardé.'
render :brouillon
end
flash.now.notice = 'Votre brouillon a bien été sauvegardé.'
end
respond_to do |format|
format.html { render :brouillon }
format.json { head :ok }
end
end