Better way to initialise things on setup.
This commit is contained in:
parent
b7c7c66013
commit
05ed5989e3
|
@ -118,5 +118,3 @@ AUTO_ADMIN_EMAIL: Optional[str] = None
|
||||||
STATOR_TOKEN: Optional[str] = None
|
STATOR_TOKEN: Optional[str] = None
|
||||||
|
|
||||||
SENTRY_ENABLED = False
|
SENTRY_ENABLED = False
|
||||||
|
|
||||||
IN_TESTS = False
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ DEBUG = bool(os.environ.get("TAKAHE__SECURITY_HAZARD__DEBUG", False))
|
||||||
# TODO: Allow better setting of allowed_hosts, if we need to
|
# TODO: Allow better setting of allowed_hosts, if we need to
|
||||||
ALLOWED_HOSTS = ["*"]
|
ALLOWED_HOSTS = ["*"]
|
||||||
|
|
||||||
|
CONN_MAX_AGE = 60
|
||||||
|
|
||||||
### User-configurable options, pulled from the environment ###
|
### User-configurable options, pulled from the environment ###
|
||||||
|
|
||||||
# Secret key
|
# Secret key
|
||||||
|
|
|
@ -3,6 +3,4 @@ from .base import * # noqa
|
||||||
# Fixed secret key
|
# Fixed secret key
|
||||||
SECRET_KEY = "testing_secret"
|
SECRET_KEY = "testing_secret"
|
||||||
|
|
||||||
IN_TESTS = True
|
|
||||||
|
|
||||||
MAIN_DOMAIN = "example.com"
|
MAIN_DOMAIN = "example.com"
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.conf import settings
|
from django.db.models.signals import post_migrate
|
||||||
|
|
||||||
|
|
||||||
class UsersConfig(AppConfig):
|
class UsersConfig(AppConfig):
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
name = "users"
|
name = "users"
|
||||||
|
|
||||||
def ready(self) -> None:
|
def data_init(self, **kwargs):
|
||||||
if not settings.IN_TESTS:
|
"""
|
||||||
# Generate the server actor keypair if needed
|
Runs after migrations or flushes to insert anything we need for first
|
||||||
from users.models import SystemActor
|
boot (or post upgrade).
|
||||||
|
"""
|
||||||
|
# Generate the server actor keypair if needed
|
||||||
|
from users.models import SystemActor
|
||||||
|
|
||||||
SystemActor.generate_keys_if_needed()
|
SystemActor.generate_keys_if_needed()
|
||||||
|
|
||||||
|
def ready(self) -> None:
|
||||||
|
post_migrate.connect(self.data_init, sender=self)
|
||||||
|
|
Loading…
Reference in New Issue