codestyle

This commit is contained in:
jonaswinkler 2020-12-11 23:33:59 +01:00
parent f0ad92e542
commit 80b47fa287
2 changed files with 12 additions and 9 deletions

View File

@ -8,11 +8,12 @@ def set_correspondent(doc_ids, correspondent):
if correspondent: if correspondent:
correspondent = Correspondent.objects.get(id=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] affected_docs = [doc.id for doc in qs]
qs.update(correspondent=correspondent) 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" return "OK"
@ -21,11 +22,12 @@ def set_document_type(doc_ids, document_type):
if document_type: if document_type:
document_type = DocumentType.objects.get(id=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] affected_docs = [doc.id for doc in qs]
qs.update(document_type=document_type) 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" return "OK"
@ -38,10 +40,11 @@ def add_tag(doc_ids, tag):
DocumentTagRelationship = Document.tags.through DocumentTagRelationship = Document.tags.through
DocumentTagRelationship.objects.bulk_create([ 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" return "OK"
@ -58,7 +61,7 @@ def remove_tag(doc_ids, tag):
Q(tag_id=tag) Q(tag_id=tag)
).delete() ).delete()
async_task("documents.tasks.bulk_rename_files", affected_docs) async_task("documents.tasks.bulk_rename_files", document_ids=affected_docs)
return "OK" return "OK"

View File

@ -90,7 +90,7 @@ def sanity_check():
return "No issues detected." return "No issues detected."
def bulk_rename_files(ids): def bulk_rename_files(document_ids):
qs = Document.objects.filter(id__in=ids) qs = Document.objects.filter(id__in=document_ids)
for doc in qs: for doc in qs:
post_save.send(Document, instance=doc, created=False) post_save.send(Document, instance=doc, created=False)