6e28f1260a
…a specific migration is targeted.
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from django.apps import AppConfig
|
|
from django.db.models.signals import post_migrate
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
class KFetAuthConfig(AppConfig):
|
|
name = 'kfet.auth'
|
|
label = 'kfetauth'
|
|
verbose_name = _("K-Fêt - Authentification et Autorisation")
|
|
|
|
def ready(self):
|
|
from . import signals # noqa
|
|
post_migrate.connect(finish_setup_kfet_generic_user, sender=self)
|
|
|
|
|
|
def finish_setup_kfet_generic_user(sender, apps, **kwargs):
|
|
from kfet.models import Account
|
|
from .utils import setup_kfet_generic_user
|
|
# Even if no kfetauth migration has been applied, the post_migrate signal
|
|
# is issued for KFetAuthConfig.
|
|
# Before finishing setup of the kfet generic user, check dependencies are
|
|
# ready: kfet.Account model and gestion.Profile (old schema may not use
|
|
# this model).
|
|
try:
|
|
apps.get_model('kfet', 'Account')
|
|
apps.get_model('gestion', 'Profile')
|
|
Account.objects.get_generic()
|
|
except (LookupError, Account.DoesNotExist):
|
|
return
|
|
|
|
setup_kfet_generic_user()
|