fix(fork): don't fail when user submit twice en_construction (from 2 tabs)

This commit is contained in:
Colin Darie 2023-05-11 16:52:10 +02:00
parent d3028f5570
commit 059dabb5ac
4 changed files with 23 additions and 1 deletions

View file

@ -15,6 +15,7 @@ module Users
before_action :ensure_dossier_can_be_viewed, only: [:show]
before_action :forbid_invite_submission!, only: [:submit_brouillon]
before_action :forbid_closed_submission!, only: [:submit_brouillon]
before_action :set_dossier_as_editing_fork, only: [:submit_en_construction]
before_action :show_demarche_en_test_banner
before_action :store_user_location!, only: :new
@ -215,7 +216,6 @@ module Users
end
def submit_en_construction
@dossier = dossier.find_editing_fork(dossier.user)
@dossier = dossier_with_champs(pj_template: false)
errors = submit_dossier_and_compute_errors
@ -471,6 +471,15 @@ module Users
DossierPreloader.load_one(dossier, pj_template:)
end
def set_dossier_as_editing_fork
@dossier = dossier.find_editing_fork(dossier.user)
return if @dossier.present?
flash[:alert] = t('users.dossiers.en_construction_submitted')
redirect_to dossier_path(dossier)
end
def should_change_groupe_instructeur?
if params[:dossier].key?(:groupe_instructeur_id)
groupe_instructeur_id = params[:dossier][:groupe_instructeur_id]