mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-16 21:55:37 -05:00
Remove the None case
This commit is contained in:
@@ -44,7 +44,7 @@ class TagAdmin(GuardedModelAdmin, TreeNodeModelAdmin):
|
||||
|
||||
# sync parent tags on documents if changed
|
||||
new_parent = obj.get_parent()
|
||||
if old_parent != new_parent:
|
||||
if new_parent and old_parent != new_parent:
|
||||
update_document_parent_tags(obj, new_parent)
|
||||
|
||||
|
||||
|
@@ -517,14 +517,11 @@ def check_scheduled_workflows():
|
||||
)
|
||||
|
||||
|
||||
def update_document_parent_tags(tag: Tag, new_parent: Tag | None) -> None:
|
||||
def update_document_parent_tags(tag: Tag, new_parent: Tag) -> None:
|
||||
"""
|
||||
When a tag's parent changes, ensure all documents containing the tag also have
|
||||
the parent tag (and its ancestors) applied.
|
||||
"""
|
||||
if new_parent is None:
|
||||
return
|
||||
|
||||
DocumentTagRelationship = Document.tags.through
|
||||
|
||||
doc_ids: list[int] = list(
|
||||
|
@@ -346,7 +346,7 @@ class TagViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
|
||||
old_parent = self.get_object().get_parent()
|
||||
tag = serializer.save()
|
||||
new_parent = tag.get_parent()
|
||||
if old_parent != new_parent:
|
||||
if new_parent and old_parent != new_parent:
|
||||
update_document_parent_tags(tag, new_parent)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user