From 7353348d7abd38fae661ef74db11591e5f5b420f Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 20 Sep 2020 09:07:51 +0200 Subject: [PATCH] Rollback transaction when checking an add permission (experimental) --- apps/permission/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/permission/models.py b/apps/permission/models.py index ee7d3ec4..17214894 100644 --- a/apps/permission/models.py +++ b/apps/permission/models.py @@ -43,6 +43,7 @@ class InstancedPermission: obj = copy(obj) obj.pk = 0 with transaction.atomic(): + sid = transaction.savepoint() for o in self.model.model_class().objects.filter(pk=0).all(): o._force_delete = True Model.delete(o) @@ -65,6 +66,7 @@ class InstancedPermission: obj._no_signal = True obj._force_delete = True Model.delete(obj) + transaction.savepoint_rollback(sid) return ret