Merge pull request #3487 from paperless-ngx/fix/issue-3484

Fix: exclude consumer & AnonymousUser users from export manifest
This commit is contained in:
shamoon 2023-06-01 11:15:58 -07:00 committed by GitHub
commit eb0f35219c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -250,7 +250,12 @@ class Command(BaseCommand):
manifest += json.loads(serializers.serialize("json", Group.objects.all()))
manifest += json.loads(serializers.serialize("json", User.objects.all()))
manifest += json.loads(
serializers.serialize(
"json",
User.objects.exclude(username__in=["consumer", "AnonymousUser"]),
),
)
manifest += json.loads(
serializers.serialize("json", UiSettings.objects.all()),

View File

@ -141,7 +141,14 @@ class TestExportImport(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
manifest = self._do_export(use_filename_format=use_filename_format)
self.assertEqual(len(manifest), 12)
self.assertEqual(len(manifest), 10)
# dont include consumer or AnonymousUser users
self.assertEqual(
len(list(filter(lambda e: e["model"] == "auth.user", manifest))),
1,
)
self.assertEqual(
len(list(filter(lambda e: e["model"] == "documents.document", manifest))),
4,