2014-01-05 05:49:35 +08:00
|
|
|
from django.apps import AppConfig
|
2015-01-28 20:35:27 +08:00
|
|
|
from django.core import checks
|
2014-11-25 20:35:39 +08:00
|
|
|
from django.db.models.signals import post_migrate
|
2017-01-27 03:58:33 +08:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2014-01-05 05:49:35 +08:00
|
|
|
|
2017-05-27 20:35:02 +08:00
|
|
|
from . import get_user_model
|
2016-04-06 10:58:22 +08:00
|
|
|
from .checks import check_models_permissions, check_user_model
|
2014-11-25 20:35:39 +08:00
|
|
|
from .management import create_permissions
|
2017-05-27 20:35:02 +08:00
|
|
|
from .signals import user_logged_in
|
2014-11-25 20:35:39 +08:00
|
|
|
|
2014-01-05 05:49:35 +08:00
|
|
|
|
2016-10-19 08:47:29 +08:00
|
|
|
class AuthConfig(AppConfig):
|
2014-01-05 05:49:35 +08:00
|
|
|
name = 'django.contrib.auth'
|
2014-03-06 23:03:25 +08:00
|
|
|
verbose_name = _("Authentication and Authorization")
|
2014-01-25 05:43:00 +08:00
|
|
|
|
|
|
|
def ready(self):
|
2016-03-29 06:33:29 +08:00
|
|
|
post_migrate.connect(
|
|
|
|
create_permissions,
|
|
|
|
dispatch_uid="django.contrib.auth.management.create_permissions"
|
|
|
|
)
|
2017-05-27 20:35:02 +08:00
|
|
|
if hasattr(get_user_model(), 'last_login'):
|
|
|
|
from .models import update_last_login
|
|
|
|
user_logged_in.connect(update_last_login, dispatch_uid='update_last_login')
|
2016-10-19 08:47:29 +08:00
|
|
|
checks.register(check_user_model, checks.Tags.models)
|
2016-04-06 10:58:22 +08:00
|
|
|
checks.register(check_models_permissions, checks.Tags.models)
|