From 80b47fa287aaaf637feb31073849996cd54fca0a Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Fri, 11 Dec 2020 23:33:59 +0100 Subject: [PATCH] codestyle --- src/documents/bulk_edit.py | 17 ++++++++++------- src/documents/tasks.py | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/documents/bulk_edit.py b/src/documents/bulk_edit.py index 1349f9d54..aa5b8ea3f 100644 --- a/src/documents/bulk_edit.py +++ b/src/documents/bulk_edit.py @@ -8,11 +8,12 @@ def set_correspondent(doc_ids, correspondent): if correspondent: correspondent = Correspondent.objects.get(id=correspondent) - qs = Document.objects.filter(Q(id__in=doc_ids) & ~Q(correspondent=correspondent)) + qs = Document.objects.filter( + Q(id__in=doc_ids) & ~Q(correspondent=correspondent)) affected_docs = [doc.id for doc in qs] qs.update(correspondent=correspondent) - async_task("documents.tasks.bulk_rename_files", affected_docs) + async_task("documents.tasks.bulk_rename_files", document_ids=affected_docs) return "OK" @@ -21,11 +22,12 @@ def set_document_type(doc_ids, document_type): if document_type: document_type = DocumentType.objects.get(id=document_type) - qs = Document.objects.filter(Q(id__in=doc_ids) & ~Q(document_type=document_type)) + qs = Document.objects.filter( + Q(id__in=doc_ids) & ~Q(document_type=document_type)) affected_docs = [doc.id for doc in qs] qs.update(document_type=document_type) - async_task("documents.tasks.bulk_rename_files", affected_docs) + async_task("documents.tasks.bulk_rename_files", document_ids=affected_docs) return "OK" @@ -38,10 +40,11 @@ def add_tag(doc_ids, tag): DocumentTagRelationship = Document.tags.through DocumentTagRelationship.objects.bulk_create([ - DocumentTagRelationship(document_id=doc, tag_id=tag) for doc in affected_docs + DocumentTagRelationship( + document_id=doc, tag_id=tag) for doc in affected_docs ]) - async_task("documents.tasks.bulk_rename_files", affected_docs) + async_task("documents.tasks.bulk_rename_files", document_ids=affected_docs) return "OK" @@ -58,7 +61,7 @@ def remove_tag(doc_ids, tag): Q(tag_id=tag) ).delete() - async_task("documents.tasks.bulk_rename_files", affected_docs) + async_task("documents.tasks.bulk_rename_files", document_ids=affected_docs) return "OK" diff --git a/src/documents/tasks.py b/src/documents/tasks.py index af4c91448..fafe6e10f 100644 --- a/src/documents/tasks.py +++ b/src/documents/tasks.py @@ -90,7 +90,7 @@ def sanity_check(): return "No issues detected." -def bulk_rename_files(ids): - qs = Document.objects.filter(id__in=ids) +def bulk_rename_files(document_ids): + qs = Document.objects.filter(id__in=document_ids) for doc in qs: post_save.send(Document, instance=doc, created=False)