Exclude consumer & AnonymousUser users from export manifest

This commit is contained in:
shamoon 2023-05-30 20:51:25 -07:00
parent 30316179a0
commit 243598ae50
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,