summaryrefslogtreecommitdiffstats
path: root/users/apps.py
blob: 67183adfa6d24a169e4e1c859c6e5a550a6f5ab5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from django.apps import AppConfig
from django.db.models.signals import post_migrate


class UsersConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "users"

    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)