Remove the None case

This commit is contained in:
shamoon
2025-09-12 21:08:16 -07:00
parent 74c864f7f2
commit 08102c95b5
3 changed files with 3 additions and 6 deletions

View File

@@ -44,7 +44,7 @@ class TagAdmin(GuardedModelAdmin, TreeNodeModelAdmin):
# sync parent tags on documents if changed # sync parent tags on documents if changed
new_parent = obj.get_parent() 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) update_document_parent_tags(obj, new_parent)

View File

@@ -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 When a tag's parent changes, ensure all documents containing the tag also have
the parent tag (and its ancestors) applied. the parent tag (and its ancestors) applied.
""" """
if new_parent is None:
return
DocumentTagRelationship = Document.tags.through DocumentTagRelationship = Document.tags.through
doc_ids: list[int] = list( doc_ids: list[int] = list(

View File

@@ -346,7 +346,7 @@ class TagViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin):
old_parent = self.get_object().get_parent() old_parent = self.get_object().get_parent()
tag = serializer.save() tag = serializer.save()
new_parent = tag.get_parent() 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) update_document_parent_tags(tag, new_parent)