fix database locked error

This commit is contained in:
Jonas Winkler 2023-03-03 23:30:12 +01:00
parent 3dbb7e5781
commit c87ca25f22
2 changed files with 1 additions and 12 deletions

View File

@ -8,7 +8,6 @@ from documents.models import StoragePath
from documents.permissions import set_permissions_for_object
from documents.tasks import bulk_update_documents
from documents.tasks import update_document_archive_file
from documents.tasks import update_owner_for_object
def set_correspondent(doc_ids, correspondent):
@ -136,7 +135,7 @@ def set_permissions(doc_ids, set_permissions, owner=None):
qs = Document.objects.filter(id__in=doc_ids)
update_owner_for_object.delay(document_ids=doc_ids, owner=owner)
qs.update(owner=owner)
for doc in qs:
set_permissions_for_object(set_permissions, doc)

View File

@ -13,7 +13,6 @@ from asgiref.sync import async_to_sync
from celery import shared_task
from channels.layers import get_channel_layer
from django.conf import settings
from django.contrib.auth.models import User
from django.db import transaction
from django.db.models.signals import post_save
from documents import barcodes
@ -312,12 +311,3 @@ def update_document_archive_file(document_id):
)
finally:
parser.cleanup()
@shared_task
def update_owner_for_object(document_ids, owner):
documents = Document.objects.filter(id__in=document_ids)
ownerUser = User.objects.get(pk=owner) if owner is not None else None
for document in documents:
document.owner = ownerUser if owner is not None else None
document.save()