A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
fixes #331
jonaswinkler623893b528f3
diff --git a/src/documents/models.py b/src/documents/models.pyindex 3f0e331d0..928b8aa4d 100755--- a/src/documents/models.py+++ b/src/documents/models.py@@ -12,6 +12,7 @@ from django.conf import settingsfrom django.contrib.auth.models import Userfrom django.db import modelsfrom django.utils import timezone+from django.utils.timezone import is_awarefrom django.utils.translation import gettext_lazy as _@@ -233,7 +234,10 @@ class Document(models.Model):verbose_name_plural = _("documents")def __str__(self):- created = datetime.date.isoformat(self.created)+ if is_aware(self.created):+ created = timezone.localdate(self.created).isoformat()+ else:+ created = datetime.date.isoformat(self.created)if self.correspondent and self.title:return f"{created} {self.correspondent} {self.title}"else:diff --git a/src/documents/tests/test_document_model.py b/src/documents/tests/test_document_model.pyindex 74bd9a2a7..87261ecd9 100644--- a/src/documents/tests/test_document_model.py+++ b/src/documents/tests/test_document_model.py@@ -1,10 +1,10 @@import shutilimport tempfile-from datetime import datetimefrom pathlib import Pathfrom unittest import mockfrom django.test import TestCase, override_settings+from django.utils import timezonefrom ..models import Document, Correspondent@@ -47,20 +47,20 @@ class TestDocument(TestCase):def test_file_name(self):- doc = Document(mime_type="application/pdf", title="test", created=datetime(2020, 12, 25))+ doc = Document(mime_type="application/pdf", title="test", created=timezone.datetime(2020, 12, 25))self.assertEqual(doc.get_public_filename(), "2020-12-25 test.pdf")def test_file_name_jpg(self):- doc = Document(mime_type="image/jpeg", title="test", created=datetime(2020, 12, 25))+ doc = Document(mime_type="image/jpeg", title="test", created=timezone.datetime(2020, 12, 25))self.assertEqual(doc.get_public_filename(), "2020-12-25 test.jpg")def test_file_name_unknown(self):- doc = Document(mime_type="application/zip", title="test", created=datetime(2020, 12, 25))+ doc = Document(mime_type="application/zip", title="test", created=timezone.datetime(2020, 12, 25))self.assertEqual(doc.get_public_filename(), "2020-12-25 test.zip")def test_file_name_invalid_type(self):- doc = Document(mime_type="image/jpegasd", title="test", created=datetime(2020, 12, 25))+ doc = Document(mime_type="image/jpegasd", title="test", created=timezone.datetime(2020, 12, 25))self.assertEqual(doc.get_public_filename(), "2020-12-25 test")