A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix #384: duplicate tags due to case insensitivity
Daniel Quinnf1e1bb4deb26
diff --git a/src/documents/models.py b/src/documents/models.pyindex 7390c1d3c..58ac66123 100644--- a/src/documents/models.py+++ b/src/documents/models.py@@ -442,8 +442,10 @@ class FileInfo:def _get_tags(cls, tags):r = []for t in tags.split(","):- r.append(- Tag.objects.get_or_create(slug=t, defaults={"name": t})[0])+ r.append(Tag.objects.get_or_create(+ slug=t.lower(),+ defaults={"name": t}+ )[0])return tuple(r)@classmethoddiff --git a/src/documents/tests/test_consumer.py b/src/documents/tests/test_consumer.pyindex b401f9477..3f5c69774 100644--- a/src/documents/tests/test_consumer.py+++ b/src/documents/tests/test_consumer.py@@ -3,7 +3,7 @@ from unittest import mockfrom tempfile import TemporaryDirectoryfrom ..consumer import Consumer-from ..models import FileInfo+from ..models import FileInfo, Tagclass TestConsumer(TestCase):@@ -190,6 +190,20 @@ class TestAttributes(TestCase):())+ def test_case_insensitive_tag_creation(self):+ """+ Tags should be detected and created as lower case.+ :return:+ """++ path = "Title - Correspondent - tAg1,TAG2.pdf"+ self.assertEqual(len(FileInfo.from_path(path).tags), 2)++ path = "Title - Correspondent - tag1,tag2.pdf"+ self.assertEqual(len(FileInfo.from_path(path).tags), 2)++ self.assertEqual(Tag.objects.all().count(), 2)+class TestFieldPermutations(TestCase):