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