|
@@ -254,12 +254,23 @@ class DatabaseBackedControlOrganizationProvisioningService(
|
|
|
return primary_slug
|
|
|
|
|
|
def bulk_create_organization_slug_reservations(
|
|
|
- self, *, region_name: str, organization_ids_and_slugs: set[tuple[int, str]]
|
|
|
+ self,
|
|
|
+ *,
|
|
|
+ region_name: str,
|
|
|
+ organization_ids_and_slugs: set[tuple[int, str]] | None = None,
|
|
|
+ slug_mapping: dict[int, str] | None = None,
|
|
|
) -> None:
|
|
|
slug_reservations_to_create: list[OrganizationSlugReservation] = []
|
|
|
+ assert not (
|
|
|
+ organization_ids_and_slugs is not None and slug_mapping is not None
|
|
|
+ ), "Cannot provide both slug_mapping and organization_ids_and_slugs"
|
|
|
+
|
|
|
+ if organization_ids_and_slugs:
|
|
|
+ slug_mapping = dict(organization_ids_and_slugs)
|
|
|
+ assert isinstance(slug_mapping, dict), "slug_mapping must be dict now"
|
|
|
|
|
|
with outbox_context(transaction.atomic(router.db_for_write(OrganizationSlugReservation))):
|
|
|
- for org_id, slug in organization_ids_and_slugs:
|
|
|
+ for org_id, slug in slug_mapping.items():
|
|
|
slug_reservation = OrganizationSlugReservation(
|
|
|
slug=self._generate_org_slug(slug=slug, region_name=region_name),
|
|
|
organization_id=org_id,
|