Skip to content

Commit

Permalink
Error nicely if list with same name as collection already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Sep 12, 2024
1 parent d386744 commit 032a84b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions arches_references/management/commands/controlled_lists.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from arches.app.models.models import Value, Language
from arches_references.models import List
from django.core.management.base import BaseCommand, CommandError


Expand Down Expand Up @@ -67,13 +68,20 @@ def handle(self, *args, **options):
psl
)
)
else:
self.migrate_collections_to_controlled_lists(
collections_to_migrate=options["collections_to_migrate"],
host=options["host"],
overwrite=options["overwrite"],
preferred_sort_language=psl,
)

if not options["overwrite"]:
for collection_name in options["collections_to_migrate"]:
if List.objects.filter(name=collection_name).exists():
raise CommandError(
f"The collection '{collection_name}' already exists."
)

self.migrate_collections_to_controlled_lists(
collections_to_migrate=options["collections_to_migrate"],
host=options["host"],
overwrite=options["overwrite"],
preferred_sort_language=psl,
)

def migrate_collections_to_controlled_lists(
self,
Expand Down

0 comments on commit 032a84b

Please sign in to comment.