1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 01:48:21 +02:00

Improve transfer UI

This commit is contained in:
Yohann D'ANELLO
2020-07-31 21:24:23 +02:00
parent 932a546213
commit dca655949e
5 changed files with 71 additions and 17 deletions

View File

@ -4,6 +4,7 @@
import functools
import json
import operator
from time import sleep
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
@ -44,6 +45,14 @@ class InstancedPermission:
else:
oldpk = obj.pk
# Ensure previous models are deleted
count = 0
while count < 1000:
if self.model.model_class().objects.filter(pk=obj.pk).exists():
# If the object exists, that means that one permission is currently checked.
# We wait before the other permission, at most 1 second.
sleep(1)
continue
break
for o in self.model.model_class().objects.filter(pk=obj.pk).all():
o._force_delete = True
Model.delete(o)