Skip to content

Commit

Permalink
Adjust initial_setup calls for the new initialize_tenants command
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Apr 23, 2024
1 parent e022988 commit dc44cb6
Showing 1 changed file with 2 additions and 44 deletions.
46 changes: 2 additions & 44 deletions tcms/core/management/commands/initial_setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import datetime

from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.utils import timezone


class Command(BaseCommand):
Expand All @@ -23,49 +19,11 @@ def handle(self, *args, **kwargs):

if "tcms_tenants" in settings.INSTALLED_APPS:
self.stdout.write("\n4. Creating public & empty tenants:")
superuser = get_user_model().objects.filter(is_superuser=True).first()
paid_until = timezone.now() + datetime.timedelta(days=100 * 365)
call_command(
"create_tenant",
"initialize_tenants",
f"--verbosity={kwargs['verbosity']}",
"--schema_name",
"public",
"--name",
"Public tenant",
"--paid_until",
paid_until.isoformat(),
"--publicly_readable",
False,
"--owner_id",
superuser.pk,
"--organization",
"Testing department",
"--domain-domain",
"--domain",
domain,
"--domain-is_primary",
True,
)

# a special tenant for cloning
call_command(
"create_tenant",
f"--verbosity={kwargs['verbosity']}",
"--schema_name",
"empty",
"--name",
"Cloning Template",
"--paid_until",
paid_until.isoformat(),
"--publicly_readable",
False,
"--owner_id",
superuser.pk,
"--organization",
"Kiwi TCMS",
"--domain-domain",
"empty.example.org",
"--domain-is_primary",
True,
)

self.stdout.write("\n5. Setting permissions:")
Expand Down

0 comments on commit dc44cb6

Please sign in to comment.