fix tests
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
parent
b6efa3bde3
commit
d492c48657
|
@ -67,7 +67,6 @@ SHARED_APPS = [
|
|||
TENANT_APPS = [
|
||||
"django.contrib.auth",
|
||||
"django.contrib.sessions",
|
||||
"authentik.tenants",
|
||||
"authentik.admin",
|
||||
"authentik.api",
|
||||
"authentik.crypto",
|
||||
|
|
|
@ -1,10 +1,28 @@
|
|||
"""authentik tenants app"""
|
||||
from django.apps import AppConfig
|
||||
from django.db import DEFAULT_DB_ALIAS
|
||||
from django.db.models.signals import post_migrate
|
||||
|
||||
from authentik.blueprints.apps import ManagedAppConfig
|
||||
|
||||
|
||||
class AuthentikTenantsConfig(AppConfig):
|
||||
def reconcile_default_tenant(using=DEFAULT_DB_ALIAS, *args, **kwargs):
|
||||
"""Make sure default tenant exists"""
|
||||
from authentik.tenants.models import Tenant
|
||||
|
||||
Tenant.objects.using(using).update_or_create(
|
||||
defaults={"name": "Default", "ready": True},
|
||||
schema_name="public",
|
||||
)
|
||||
|
||||
|
||||
class AuthentikTenantsConfig(ManagedAppConfig):
|
||||
"""authentik tenants app"""
|
||||
|
||||
name = "authentik.tenants"
|
||||
label = "authentik_tenants"
|
||||
verbose_name = "authentik Tenants"
|
||||
default = True
|
||||
|
||||
def reconcile_default_tenant(self):
|
||||
reconcile_default_tenant()
|
||||
post_migrate.connect(reconcile_default_tenant)
|
||||
|
|
|
@ -86,6 +86,10 @@ class Tenant(TenantMixin, SerializerModel):
|
|||
class Domain(DomainMixin, SerializerModel):
|
||||
"""Tenant domain"""
|
||||
|
||||
tenant = models.ForeignKey(
|
||||
Tenant, db_index=True, related_name="domains", on_delete=models.CASCADE
|
||||
)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"Domain {self.domain}"
|
||||
|
||||
|
|
Reference in New Issue