mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 00:30:59 +00:00
Better way to initialise things on setup.
This commit is contained in:
parent
b7c7c66013
commit
05ed5989e3
4 changed files with 14 additions and 10 deletions
|
@ -118,5 +118,3 @@ AUTO_ADMIN_EMAIL: Optional[str] = None
|
|||
STATOR_TOKEN: Optional[str] = None
|
||||
|
||||
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
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
CONN_MAX_AGE = 60
|
||||
|
||||
### User-configurable options, pulled from the environment ###
|
||||
|
||||
# Secret key
|
||||
|
|
|
@ -3,6 +3,4 @@ from .base import * # noqa
|
|||
# Fixed secret key
|
||||
SECRET_KEY = "testing_secret"
|
||||
|
||||
IN_TESTS = True
|
||||
|
||||
MAIN_DOMAIN = "example.com"
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
from django.apps import AppConfig
|
||||
from django.conf import settings
|
||||
from django.db.models.signals import post_migrate
|
||||
|
||||
|
||||
class UsersConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "users"
|
||||
|
||||
def ready(self) -> None:
|
||||
if not settings.IN_TESTS:
|
||||
def data_init(self, **kwargs):
|
||||
"""
|
||||
Runs after migrations or flushes to insert anything we need for first
|
||||
boot (or post upgrade).
|
||||
"""
|
||||
# Generate the server actor keypair if needed
|
||||
from users.models import SystemActor
|
||||
|
||||
SystemActor.generate_keys_if_needed()
|
||||
|
||||
def ready(self) -> None:
|
||||
post_migrate.connect(self.data_init, sender=self)
|
||||
|
|
Loading…
Reference in a new issue