dossiers: render JSON if needed

When receiving a request that expects JSON, return a simple '200'.

This avoids the unecessary work of rendering all the HTML page (which
ultimately will not be used).
This commit is contained in:
Pierre de La Morinerie 2019-11-07 15:11:24 +00:00
parent 4125d81869
commit 5f9a9d059e

View file

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