summaryrefslogtreecommitdiffstats
path: root/users
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-22 17:06:32 -0700
committerAndrew Godwin2022-11-22 11:59:34 -0700
commit05ed5989e3436108f9a7bd443b0f79b7ee407f26 (patch)
tree0c59502ae81a45e13f0c1bf1f3f50a09fb43b162 /users
parentb7c7c66013557e093a838a84b9b0e7cbaf05e12a (diff)
downloadtakahe-05ed5989e3436108f9a7bd443b0f79b7ee407f26.tar.gz
takahe-05ed5989e3436108f9a7bd443b0f79b7ee407f26.tar.bz2
takahe-05ed5989e3436108f9a7bd443b0f79b7ee407f26.zip
Better way to initialise things on setup.
Diffstat (limited to 'users')
-rw-r--r--users/apps.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/users/apps.py b/users/apps.py
index 86a8eb3..67183ad 100644
--- a/users/apps.py
+++ b/users/apps.py
@@ -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:
- # Generate the server actor keypair if needed
- from users.models import SystemActor
+ 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()
- SystemActor.generate_keys_if_needed()
+ def ready(self) -> None:
+ post_migrate.connect(self.data_init, sender=self)