mirror of https://gitlab.crans.org/bde/nk20
Don't delete object when checking an add permission: this is useless since we rollback to the initial DB state
This commit is contained in:
parent
08e50ffc22
commit
6e80016b38
|
@ -45,6 +45,7 @@ class InstancedPermission:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
sid = transaction.savepoint()
|
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._no_signal = True
|
||||||
o._force_delete = True
|
o._force_delete = True
|
||||||
Model.delete(o)
|
Model.delete(o)
|
||||||
# An object with pk 0 wouldn't deleted. That's not normal, we alert admins.
|
# An object with pk 0 wouldn't deleted. That's not normal, we alert admins.
|
||||||
|
@ -62,10 +63,6 @@ class InstancedPermission:
|
||||||
obj._no_signal = True
|
obj._no_signal = True
|
||||||
Model.save(obj, force_insert=True)
|
Model.save(obj, force_insert=True)
|
||||||
ret = self.model.model_class().objects.filter(self.query & Q(pk=0)).exists()
|
ret = self.model.model_class().objects.filter(self.query & Q(pk=0)).exists()
|
||||||
# Delete testing object
|
|
||||||
obj._no_signal = True
|
|
||||||
obj._force_delete = True
|
|
||||||
Model.delete(obj)
|
|
||||||
transaction.savepoint_rollback(sid)
|
transaction.savepoint_rollback(sid)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue