small fixes, runs

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt 2023-11-15 17:33:50 +01:00
parent 425575ef99
commit d11721805a
No known key found for this signature in database
GPG Key ID: 9C3FA22FABF1AA8D
9 changed files with 21 additions and 13 deletions

View File

@ -39,9 +39,14 @@ class ManagedAppConfig(AppConfig):
if not meth_name.startswith(prefix):
continue
name = meth_name.replace(prefix, "")
tenants = Tenant.objects.all()
if meth_name.startswith(tenant_prefix):
tenants = Tenant.objects.get(schema_name=get_public_schema_name())
tenants = Tenant.objects.filter(ready=True)
if not meth_name.startswith(tenant_prefix):
tenants = Tenant.objects.filter(schema_name=get_public_schema_name())
try:
tenants = list(tenants)
except (DatabaseError, ProgrammingError, InternalError) as exc:
self._logger.debug("Failed to get tenants to run reconcile", name=name, exc=exc)
continue
for tenant in tenants:
with tenant:
try:

View File

@ -76,7 +76,7 @@ class BlueprintEventHandler(FileSystemEventHandler):
return
if event.is_directory:
return
for tenant in Tenant.objects.all():
for tenant in Tenant.objects.filter(ready=True):
with tenant:
if isinstance(event, FileCreatedEvent):
LOGGER.debug("new blueprint file created, starting discovery")

View File

@ -69,13 +69,13 @@ class Themes(models.TextChoices):
DARK = "dark"
def get_default_ui_footer_links():
return get_current_tenant().footer_links
class CurrentBrandSerializer(PassiveSerializer):
"""Partial brand information for styling"""
@staticmethod
def get_default_ui_footer_links():
return get_current_tenant().footer_links
matched_domain = CharField(source="domain")
branding_title = CharField()
branding_logo = CharField()

View File

@ -17,7 +17,9 @@ class InterfaceView(TemplateView):
"""Base interface view"""
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
kwargs["config_json"] = dumps(ConfigView(request=Request(self.request)).get_config().data)
kwargs["config_json"] = dumps(
ConfigView(request=Request(self.request)).get_config(self.request).data
)
kwargs["brand_json"] = dumps(CurrentBrandSerializer(self.request.brand).data)
kwargs["version_family"] = f"{LOCAL_VERSION.major}.{LOCAL_VERSION.minor}"
kwargs["version_subdomain"] = f"version-{LOCAL_VERSION.major}-{LOCAL_VERSION.minor}"

View File

@ -119,7 +119,7 @@ def worker_ready_hook(*args, **kwargs):
_run_task(task)
for task in _get_startup_tasks_all_tenants():
for tenant in Tenant.objects.all():
for tenant in Tenant.objects.filter(ready=True):
with tenant:
_run_task(task)

View File

@ -228,7 +228,7 @@ MIDDLEWARE = [
"django_tenants.middleware.default.DefaultTenantMiddleware",
"authentik.root.middleware.LoggingMiddleware",
"django_prometheus.middleware.PrometheusBeforeMiddleware",
"authentik.brands.middleware.TenantMiddleware",
"authentik.brands.middleware.BrandMiddleware",
"authentik.root.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"authentik.core.middleware.RequestIDMiddleware",

View File

@ -16,6 +16,7 @@ def create_default_tenant(apps, schema_editor):
tenant = Tenant.objects.using(db_alias).create(
schema_name="public",
name="Default",
ready=True,
avatars=CONFIG.get("avatars", "gravatar,initials"),
default_user_change_name=CONFIG.get_bool("default_user_change_name", True),
default_user_change_email=CONFIG.get_bool("default_user_change_email", False),
@ -54,6 +55,7 @@ class Migration(migrations.Migration):
),
),
("name", models.TextField()),
("ready", models.BooleanField(default=False)),
(
"avatars",
models.TextField(

View File

@ -30169,7 +30169,6 @@ components:
items:
$ref: '#/components/schemas/FooterLink'
readOnly: true
default: []
ui_theme:
allOf:
- $ref: '#/components/schemas/UiThemeEnum'

View File

@ -1,5 +1,5 @@
import "@goauthentik/admin/common/ak-crypto-certificate-search";
import "@goauthentik/admin/common/ak-flow-search/ak-branted-flow-search";
import "@goauthentik/admin/common/ak-flow-search/ak-branded-flow-search";
import {
clientTypeOptions,
issuerModeOptions,