]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix consumption template empty field checking
authorshamoon <4887959+shamoon@users.noreply.github.com>
Tue, 5 Dec 2023 17:08:36 +0000 (09:08 -0800)
committershamoon <4887959+shamoon@users.noreply.github.com>
Tue, 5 Dec 2023 17:08:43 +0000 (09:08 -0800)
src/documents/serialisers.py

index f01d1fc3ac7cf5ead667b856bb49bc5e0df7a51e..c13801c06f8271a894aa9832885452fb5651788f 100644 (file)
@@ -1175,11 +1175,23 @@ class ConsumptionTemplateSerializer(serializers.ModelSerializer):
             attrs["sources"] = {DocumentSource.MailFetch.value}
 
         # Empty strings treated as None to avoid unexpected behavior
-        if ("assign_title") in attrs and len(attrs["assign_title"]) == 0:
+        if (
+            "assign_title" in attrs
+            and attrs["assign_title"] is not None
+            and len(attrs["assign_title"]) == 0
+        ):
             attrs["assign_title"] = None
-        if "filter_filename" in attrs and len(attrs["filter_filename"]) == 0:
+        if (
+            "filter_filename" in attrs
+            and attrs["filter_filename"] is not None
+            and len(attrs["filter_filename"]) == 0
+        ):
             attrs["filter_filename"] = None
-        if "filter_path" in attrs and len(attrs["filter_path"]) == 0:
+        if (
+            "filter_path" in attrs
+            and attrs["filter_path"] is not None
+            and len(attrs["filter_path"]) == 0
+        ):
             attrs["filter_path"] = None
 
         if (