summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMichael Manfre2022-11-22 21:52:40 -0500
committerGitHub2022-11-22 19:52:40 -0700
commitcdfff32f9af75730ca560833744433f1dc07067f (patch)
treed62719a4bd3269ec33f7bcde6c1a783fcef9792e /core
parentdb0edcd2ae7ad3d191974a47b8c0da8c3fc31e80 (diff)
downloadtakahe-cdfff32f9af75730ca560833744433f1dc07067f.tar.gz
takahe-cdfff32f9af75730ca560833744433f1dc07067f.tar.bz2
takahe-cdfff32f9af75730ca560833744433f1dc07067f.zip
Content warning name customisation
Allows the name of Content Warning to be customized (e.g. to "Content Summary"). Fixes #28.
Diffstat (limited to 'core')
-rw-r--r--core/models/config.py11
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