mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Fix: export consumption templates & custom fields in exporter (#4825)
This commit is contained in:
parent
a58e8498aa
commit
90f90dc9b4
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## paperless-ngx 2.0.1
|
## 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
|
### 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))
|
- 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
|
## 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 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))
|
- 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))
|
||||||
|
@ -23,7 +23,10 @@ from guardian.models import UserObjectPermission
|
|||||||
|
|
||||||
from documents.file_handling import delete_empty_directories
|
from documents.file_handling import delete_empty_directories
|
||||||
from documents.file_handling import generate_filename
|
from documents.file_handling import generate_filename
|
||||||
|
from documents.models import ConsumptionTemplate
|
||||||
from documents.models import Correspondent
|
from documents.models import Correspondent
|
||||||
|
from documents.models import CustomField
|
||||||
|
from documents.models import CustomFieldInstance
|
||||||
from documents.models import Document
|
from documents.models import Document
|
||||||
from documents.models import DocumentType
|
from documents.models import DocumentType
|
||||||
from documents.models import Note
|
from documents.models import Note
|
||||||
@ -292,6 +295,19 @@ class Command(BaseCommand):
|
|||||||
serializers.serialize("json", GroupObjectPermission.objects.all()),
|
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 document
|
# 3. Export files from each document
|
||||||
for index, document_dict in tqdm.tqdm(
|
for index, document_dict in tqdm.tqdm(
|
||||||
enumerate(document_manifest),
|
enumerate(document_manifest),
|
||||||
|
@ -21,7 +21,10 @@ from guardian.models import UserObjectPermission
|
|||||||
from guardian.shortcuts import assign_perm
|
from guardian.shortcuts import assign_perm
|
||||||
|
|
||||||
from documents.management.commands import document_exporter
|
from documents.management.commands import document_exporter
|
||||||
|
from documents.models import ConsumptionTemplate
|
||||||
from documents.models import Correspondent
|
from documents.models import Correspondent
|
||||||
|
from documents.models import CustomField
|
||||||
|
from documents.models import CustomFieldInstance
|
||||||
from documents.models import Document
|
from documents.models import Document
|
||||||
from documents.models import DocumentType
|
from documents.models import DocumentType
|
||||||
from documents.models import Note
|
from documents.models import Note
|
||||||
@ -89,6 +92,15 @@ class TestExportImport(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
|||||||
self.dt1 = DocumentType.objects.create(name="dt")
|
self.dt1 = DocumentType.objects.create(name="dt")
|
||||||
self.c1 = Correspondent.objects.create(name="c")
|
self.c1 = Correspondent.objects.create(name="c")
|
||||||
self.sp1 = StoragePath.objects.create(path="{created_year}-{title}")
|
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.tags.add(self.t1)
|
||||||
self.d1.correspondent = self.c1
|
self.d1.correspondent = self.c1
|
||||||
@ -96,6 +108,9 @@ class TestExportImport(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
|||||||
self.d1.save()
|
self.d1.save()
|
||||||
self.d4.storage_path = self.sp1
|
self.d4.storage_path = self.sp1
|
||||||
self.d4.save()
|
self.d4.save()
|
||||||
|
|
||||||
|
self.ct1 = ConsumptionTemplate.objects.create(name="CT 1", filter_path="*")
|
||||||
|
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
def _get_document_from_manifest(self, manifest, id):
|
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)
|
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 users
|
# dont include consumer or AnonymousUser users
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user