Support bulk edit owner

This commit is contained in:
Michael Shamoon
2022-12-09 17:51:01 -08:00
parent a5ab6f2558
commit 6dc5c1de32
10 changed files with 47 additions and 37 deletions

View File

@@ -12,6 +12,7 @@ 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
@@ -284,3 +285,12 @@ 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)
for document in documents:
document.owner = ownerUser
document.save()