From 1b44a253316a84f40070264ea8134c86d1223441 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Fri, 18 Nov 2022 00:09:04 -0700 Subject: Signup and invite tweaks --- core/middleware.py | 17 +++++++++++++++++ core/models/config.py | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/middleware.py b/core/middleware.py index 8e95f06..fdb08a8 100644 --- a/core/middleware.py +++ b/core/middleware.py @@ -1,3 +1,6 @@ +from core.models import Config + + class AlwaysSecureMiddleware: """ Locks the request object as always being secure, for when it's behind @@ -11,3 +14,17 @@ class AlwaysSecureMiddleware: request.__class__.scheme = "https" response = self.get_response(request) return response + + +class ConfigLoadingMiddleware: + """ + Caches the system config every request + """ + + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): + Config.system = Config.load_system() + response = self.get_response(request) + return response diff --git a/core/models/config.py b/core/models/config.py index 4ba8375..2a27d2e 100644 --- a/core/models/config.py +++ b/core/models/config.py @@ -160,7 +160,9 @@ class Config(models.Model): site_icon: UploadedImage = static("img/icon-128.png") site_banner: UploadedImage = static("img/fjords-banner-600.jpg") - allow_signups: bool = False + signup_allowed: bool = False + signup_invite_only: bool = False + signup_text: str = "" post_length: int = 500 identity_max_per_user: int = 5 -- cgit v1.2.3