A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: Don't attempt to parse none objects during date searching
Adam Bogdał45109026774b
diff --git a/src/documents/index.py b/src/documents/index.pyindex 34b2a56c3..ebfe40e18 100644--- a/src/documents/index.py+++ b/src/documents/index.py@@ -3,6 +3,7 @@ import mathimport osfrom collections import Counterfrom contextlib import contextmanager+from datetime import datetimefrom typing import Optionalfrom dateutil.parser import isoparse@@ -371,7 +372,7 @@ class LocalDateParser(English):if isinstance(d, timespan):d.start = self.reverse_timezone_offset(d.start)d.end = self.reverse_timezone_offset(d.end)- else:+ elif isinstance(d, datetime):d = self.reverse_timezone_offset(d)return ddiff --git a/src/documents/tests/test_api_search.py b/src/documents/tests/test_api_search.pyindex 84461bb35..4cd1a367c 100644--- a/src/documents/tests/test_api_search.py+++ b/src/documents/tests/test_api_search.py@@ -455,6 +455,31 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase):# Assert subset in resultsself.assertDictEqual(result, {**result, **subset})+ def test_search_added_invalid_date(self):+ """+ GIVEN:+ - One document added right now+ WHEN:+ - Query with invalid added date+ THEN:+ - No documents returned+ """+ d1 = Document.objects.create(+ title="invoice",+ content="the thing i bought at a shop and paid with bank account",+ checksum="A",+ pk=1,+ )++ with index.open_index_writer() as writer:+ index.update_document(writer, d1)++ response = self.client.get("/api/documents/?query=added:invalid-date")+ results = response.data["results"]++ # Expect 0 document returned+ self.assertEqual(len(results), 0)+@mock.patch("documents.index.autocomplete")def test_search_autocomplete_limits(self, m):"""