Merge pull request #9932 from colinux/lock-submit-fork
Correctif: ETQ usager, je ne peux pas soumettre 2x mes modifications en parallèle
This commit is contained in:
commit
50b9813b4d
7 changed files with 81 additions and 1 deletions
16
app/controllers/concerns/lockable_concern.rb
Normal file
16
app/controllers/concerns/lockable_concern.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module LockableConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
def lock_action(key)
|
||||
lock = Kredis.flag(key, config: :volatile)
|
||||
head :locked and return if lock.marked?
|
||||
|
||||
lock.mark(expires_in: 10.seconds)
|
||||
|
||||
yield
|
||||
|
||||
lock.remove
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,6 +2,7 @@ module Users
|
|||
class DossiersController < UserController
|
||||
include DossierHelper
|
||||
include TurboChampsConcern
|
||||
include LockableConcern
|
||||
|
||||
layout 'procedure_context', only: [:identite, :update_identite, :siret, :update_siret]
|
||||
|
||||
|
@ -19,6 +20,10 @@ module Users
|
|||
before_action :show_demarche_en_test_banner
|
||||
before_action :store_user_location!, only: :new
|
||||
|
||||
around_action only: :submit_en_construction do |_controller, action|
|
||||
lock_action("lock-submit-en-construction-#{@dossier.id}", &action)
|
||||
end
|
||||
|
||||
def index
|
||||
ordered_dossiers = Dossier.includes(:procedure).order_by_updated_at
|
||||
deleted_dossiers = current_user.deleted_dossiers.includes(:procedure).order_by_updated_at
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue