fix(transfer): remove discarded dossiers from transfers
This commit is contained in:
parent
01b0d15f5a
commit
4aa573a75d
3 changed files with 4 additions and 3 deletions
|
@ -678,6 +678,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
update!(dossier_transfer_id: nil)
|
||||
discard!
|
||||
end
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class DossierTransfer < ApplicationRecord
|
|||
}
|
||||
end)
|
||||
transfer.dossiers.update_all(user_id: current_user.id)
|
||||
transfer.destroy
|
||||
transfer.destroy_and_nullify
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -48,7 +48,7 @@ class DossierTransfer < ApplicationRecord
|
|||
def destroy_and_nullify
|
||||
transaction do
|
||||
# Rails cascading is not working with default scopes. Doing nullify cascade manually.
|
||||
Dossier.with_discarded.where(transfer: self).update_all(dossier_transfer_id: nil)
|
||||
dossiers.with_discarded.update_all(dossier_transfer_id: nil)
|
||||
destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -191,7 +191,7 @@ class User < ApplicationRecord
|
|||
.where.not(operation: DossierOperationLog.operations.fetch(:supprimer))
|
||||
.destroy_all
|
||||
dossiers.with_discarded.discarded.destroy_all
|
||||
dossiers.update_all(deleted_user_email_never_send: email, user_id: nil)
|
||||
dossiers.update_all(deleted_user_email_never_send: email, user_id: nil, dossier_transfer_id: nil)
|
||||
destroy!
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue