1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00

Rollback transaction when checking an add permission (experimental)

This commit is contained in:
Yohann D'ANELLO 2020-09-20 09:07:51 +02:00
parent f63e2e088e
commit 7353348d7a

View File

@ -43,6 +43,7 @@ class InstancedPermission:
obj = copy(obj) obj = copy(obj)
obj.pk = 0 obj.pk = 0
with transaction.atomic(): with transaction.atomic():
sid = transaction.savepoint()
for o in self.model.model_class().objects.filter(pk=0).all(): for o in self.model.model_class().objects.filter(pk=0).all():
o._force_delete = True o._force_delete = True
Model.delete(o) Model.delete(o)
@ -65,6 +66,7 @@ class InstancedPermission:
obj._no_signal = True obj._no_signal = True
obj._force_delete = True obj._force_delete = True
Model.delete(obj) Model.delete(obj)
transaction.savepoint_rollback(sid)
return ret return ret