From cdfff32f9af75730ca560833744433f1dc07067f Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Tue, 22 Nov 2022 21:52:40 -0500 Subject: Content warning name customisation Allows the name of Content Warning to be customized (e.g. to "Content Summary"). Fixes #28.--- core/models/config.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'core/models') 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__ @@ -55,6 +56,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): """ @@ -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 -- cgit v1.2.3