diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/apps.py | 3 | ||||
-rw-r--r-- | core/context.py | 2 | ||||
-rw-r--r-- | core/migrations/0002_alter_config_image.py | 28 | ||||
-rw-r--r-- | core/models/config.py | 11 |
4 files changed, 36 insertions, 8 deletions
diff --git a/core/apps.py b/core/apps.py index 6098f6b..54693d5 100644 --- a/core/apps.py +++ b/core/apps.py @@ -9,4 +9,7 @@ class CoreConfig(AppConfig): name = "core" def ready(self) -> None: + from core.models import Config + + Config.system = Config.load_system() jsonld.set_document_loader(builtin_document_loader) diff --git a/core/context.py b/core/context.py index a4aabf5..1db3436 100644 --- a/core/context.py +++ b/core/context.py @@ -3,7 +3,7 @@ from core.models import Config def config_context(request): return { - "config": Config.load_system(), + "config": Config.system, "config_identity": ( Config.load_identity(request.identity) if request.identity else None ), diff --git a/core/migrations/0002_alter_config_image.py b/core/migrations/0002_alter_config_image.py new file mode 100644 index 0000000..86dcebb --- /dev/null +++ b/core/migrations/0002_alter_config_image.py @@ -0,0 +1,28 @@ +# Generated by Django 4.1.3 on 2022-11-18 01:40 + +import functools + +from django.db import migrations, models + +import core.uploads + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0001_initial"), + ] + + operations = [ + migrations.AlterField( + model_name="config", + name="image", + field=models.ImageField( + blank=True, + null=True, + upload_to=functools.partial( + core.uploads.upload_namer, *("config",), **{} + ), + ), + ), + ] diff --git a/core/models/config.py b/core/models/config.py index 021bf67..4ba8375 100644 --- a/core/models/config.py +++ b/core/models/config.py @@ -5,7 +5,6 @@ import pydantic from django.core.files import File from django.db import models from django.templatetags.static import static -from django.utils.functional import classproperty from core.uploads import upload_namer from takahe import __version__ @@ -54,11 +53,6 @@ class Config(models.Model): ("key", "user", "identity"), ] - @classproperty - def system(cls): - cls.system = cls.load_system() - return cls.system - system: ClassVar["Config.ConfigOptions"] # type: ignore @classmethod @@ -160,13 +154,16 @@ class Config(models.Model): version: str = __version__ - site_name: str = "takahē" + site_name: str = "Takahē" highlight_color: str = "#449c8c" site_about: str = "<h2>Welcome!</h2>\n\nThis is a community running Takahē." site_icon: UploadedImage = static("img/icon-128.png") site_banner: UploadedImage = static("img/fjords-banner-600.jpg") + allow_signups: bool = False + post_length: int = 500 + identity_max_per_user: int = 5 identity_max_age: int = 24 * 60 * 60 class UserOptions(pydantic.BaseModel): |