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:
parent
4125d81869
commit
5f9a9d059e
1 changed files with 11 additions and 10 deletions
|
@ -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?
|
||||||
flash.now.alert = errors
|
|
||||||
render :brouillon
|
|
||||||
else
|
|
||||||
if passage_en_construction?
|
|
||||||
@dossier.en_construction!
|
@dossier.en_construction!
|
||||||
NotificationMailer.send_initiated_notification(@dossier).deliver_later
|
NotificationMailer.send_initiated_notification(@dossier).deliver_later
|
||||||
redirect_to merci_dossier_path(@dossier)
|
return redirect_to(merci_dossier_path(@dossier))
|
||||||
|
elsif errors.present?
|
||||||
|
flash.now.alert = errors
|
||||||
else
|
else
|
||||||
flash.now.notice = 'Votre brouillon a bien été sauvegardé.'
|
flash.now.notice = 'Votre brouillon a bien été sauvegardé.'
|
||||||
render :brouillon
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :brouillon }
|
||||||
|
format.json { head :ok }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue