A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: export consumption templates & custom fields in exporter (#4825)
shamoon90f90dc9b4f7
diff --git a/docs/changelog.md b/docs/changelog.mdindex 1ef1a9282..2962c753d 100644--- a/docs/changelog.md+++ b/docs/changelog.md@@ -2,6 +2,10 @@## paperless-ngx 2.0.1+### Please Note++Exports generated in Paperless-ngx v2.0.0–2.0.1 will **not** contain consumption templates or custom fields, we recommend users upgrade to at least v2.1.+### Bug Fixes- Fix: Increase field the length for consumption template source [@stumpylog](https://github.com/stumpylog) ([#4719](https://github.com/paperless-ngx/paperless-ngx/pull/4719))@@ -22,6 +26,10 @@## paperless-ngx 2.0.0+### Please Note++Exports generated in Paperless-ngx v2.0.0–2.0.1 will **not** contain consumption templates or custom fields, we recommend users upgrade to at least v2.1.+### Breaking Changes- Breaking: Rename the environment variable for self-signed email certificates [@stumpylog](https://github.com/stumpylog) ([#4346](https://github.com/paperless-ngx/paperless-ngx/pull/4346))diff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.pyindex 05c78ea08..4f3cb937a 100644--- a/src/documents/management/commands/document_exporter.py+++ b/src/documents/management/commands/document_exporter.py@@ -23,7 +23,10 @@ from guardian.models import UserObjectPermissionfrom documents.file_handling import delete_empty_directoriesfrom documents.file_handling import generate_filename+from documents.models import ConsumptionTemplatefrom documents.models import Correspondent+from documents.models import CustomField+from documents.models import CustomFieldInstancefrom documents.models import Documentfrom documents.models import DocumentTypefrom documents.models import Note@@ -292,6 +295,19 @@ class Command(BaseCommand):serializers.serialize("json", GroupObjectPermission.objects.all()),)+ manifest += json.loads(+ serializers.serialize("json", ConsumptionTemplate.objects.all()),+ )++ manifest += json.loads(+ serializers.serialize("json", CustomField.objects.all()),+ )++ if not self.split_manifest:+ manifest += json.loads(+ serializers.serialize("json", CustomFieldInstance.objects.all()),+ )+# 3. Export files from each documentfor index, document_dict in tqdm.tqdm(enumerate(document_manifest),diff --git a/src/documents/tests/test_management_exporter.py b/src/documents/tests/test_management_exporter.pyindex 10a272991..b4dc5720a 100644--- a/src/documents/tests/test_management_exporter.py+++ b/src/documents/tests/test_management_exporter.py@@ -21,7 +21,10 @@ from guardian.models import UserObjectPermissionfrom guardian.shortcuts import assign_permfrom documents.management.commands import document_exporter+from documents.models import ConsumptionTemplatefrom documents.models import Correspondent+from documents.models import CustomField+from documents.models import CustomFieldInstancefrom documents.models import Documentfrom documents.models import DocumentTypefrom documents.models import Note@@ -89,6 +92,15 @@ class TestExportImport(DirectoriesMixin, FileSystemAssertsMixin, TestCase):self.dt1 = DocumentType.objects.create(name="dt")self.c1 = Correspondent.objects.create(name="c")self.sp1 = StoragePath.objects.create(path="{created_year}-{title}")+ self.cf1 = CustomField.objects.create(+ name="Custom Field 1",+ data_type=CustomField.FieldDataType.STRING,+ )+ self.cfi1 = CustomFieldInstance.objects.create(+ field=self.cf1,+ value_text="cf instance 1",+ document=self.d1,+ )self.d1.tags.add(self.t1)self.d1.correspondent = self.c1@@ -96,6 +108,9 @@ class TestExportImport(DirectoriesMixin, FileSystemAssertsMixin, TestCase):self.d1.save()self.d4.storage_path = self.sp1self.d4.save()++ self.ct1 = ConsumptionTemplate.objects.create(name="CT 1", filter_path="*")+super().setUp()def _get_document_from_manifest(self, manifest, id):@@ -153,7 +168,7 @@ class TestExportImport(DirectoriesMixin, FileSystemAssertsMixin, TestCase):manifest = self._do_export(use_filename_format=use_filename_format)- self.assertEqual(len(manifest), 169)+ self.assertEqual(len(manifest), 172)# dont include consumer or AnonymousUser usersself.assertEqual(