2017-09-13 01:57:31 +02:00
|
|
|
from django.apps import AppConfig
|
2017-09-21 23:39:27 +02:00
|
|
|
from django.db.models.signals import post_migrate
|
2017-09-13 01:57:31 +02:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
|
|
|
|
|
|
class KFetAuthConfig(AppConfig):
|
|
|
|
name = 'kfet.auth'
|
|
|
|
label = 'kfetauth'
|
|
|
|
verbose_name = _("K-Fêt - Authentification et Autorisation")
|
2017-09-21 23:39:27 +02:00
|
|
|
|
|
|
|
def ready(self):
|
2017-09-25 17:16:19 +02:00
|
|
|
from . import signals # noqa
|
2017-10-26 15:42:28 +02:00
|
|
|
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()
|