diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/models/config.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/models/config.py b/core/models/config.py index d69205c..dca8a0c 100644 --- a/core/models/config.py +++ b/core/models/config.py @@ -5,6 +5,7 @@ import pydantic from django.core.files import File from django.db import models from django.templatetags.static import static +from django.utils.functional import lazy from core.uploads import upload_namer from takahe import __version__ @@ -56,6 +57,15 @@ class Config(models.Model): system: ClassVar["Config.ConfigOptions"] # type: ignore @classmethod + def lazy_system_value(cls, key: str): + """ + Lazily load a System.Config value + """ + if key not in cls.SystemOptions.__fields__: + raise KeyError(f"Undefined SystemOption for {key}") + return lazy(lambda: getattr(Config.system, key)) + + @classmethod def load_values(cls, options_class, filters): """ Loads config options and returns an object with them @@ -166,6 +176,7 @@ class Config(models.Model): signup_allowed: bool = True signup_invite_only: bool = False signup_text: str = "" + content_warning_text: str = "Content Warning" post_length: int = 500 identity_min_length: int = 2 |