tenants: handle all errors in default_locale
closes #3457 Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
371f1878a8
commit
aabb8af486
|
@ -4,12 +4,15 @@ from uuid import uuid4
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from rest_framework.serializers import Serializer
|
from rest_framework.serializers import Serializer
|
||||||
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.crypto.models import CertificateKeyPair
|
from authentik.crypto.models import CertificateKeyPair
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
from authentik.lib.models import SerializerModel
|
from authentik.lib.models import SerializerModel
|
||||||
from authentik.lib.utils.time import timedelta_string_validator
|
from authentik.lib.utils.time import timedelta_string_validator
|
||||||
|
|
||||||
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class Tenant(SerializerModel):
|
class Tenant(SerializerModel):
|
||||||
"""Single tenant"""
|
"""Single tenant"""
|
||||||
|
@ -75,7 +78,12 @@ class Tenant(SerializerModel):
|
||||||
@property
|
@property
|
||||||
def default_locale(self) -> str:
|
def default_locale(self) -> str:
|
||||||
"""Get default locale"""
|
"""Get default locale"""
|
||||||
|
try:
|
||||||
return self.attributes.get("settings", {}).get("locale", "")
|
return self.attributes.get("settings", {}).get("locale", "")
|
||||||
|
# pylint: disable=broad-except
|
||||||
|
except Exception as exc:
|
||||||
|
LOGGER.warning("Failed to get default locale", exc=exc)
|
||||||
|
return ""
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
if self.default:
|
if self.default:
|
||||||
|
|
Reference in a new issue