[1.7.x] Fixed #22195 -- Used constants to define built-in tags for check framework.
Thanks Elvard for the patch.
Backport of b513fa5fc6
from master
This commit is contained in:
parent
0b43308e2d
commit
32e6237450
|
@ -11,7 +11,7 @@ class SimpleAdminConfig(AppConfig):
|
||||||
verbose_name = _("Administration")
|
verbose_name = _("Administration")
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
checks.register('admin')(check_admin_app)
|
checks.register(checks.Tags.admin)(check_admin_app)
|
||||||
|
|
||||||
|
|
||||||
class AdminConfig(SimpleAdminConfig):
|
class AdminConfig(SimpleAdminConfig):
|
||||||
|
|
|
@ -10,4 +10,4 @@ class AuthConfig(AppConfig):
|
||||||
verbose_name = _("Authentication and Authorization")
|
verbose_name = _("Authentication and Authorization")
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
checks.register('models')(check_user_model)
|
checks.register(checks.Tags.models)(check_user_model)
|
||||||
|
|
|
@ -9,4 +9,4 @@ class ContentTypesConfig(AppConfig):
|
||||||
verbose_name = _("Content Types")
|
verbose_name = _("Content Types")
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
checks.register('models')(check_generic_foreign_keys)
|
checks.register(checks.Tags.models)(check_generic_foreign_keys)
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||||
from .messages import (CheckMessage,
|
from .messages import (CheckMessage,
|
||||||
Debug, Info, Warning, Error, Critical,
|
Debug, Info, Warning, Error, Critical,
|
||||||
DEBUG, INFO, WARNING, ERROR, CRITICAL)
|
DEBUG, INFO, WARNING, ERROR, CRITICAL)
|
||||||
from .registry import register, run_checks, tag_exists
|
from .registry import register, run_checks, tag_exists, Tags
|
||||||
|
|
||||||
# Import these to force registration of checks
|
# Import these to force registration of checks
|
||||||
import django.core.checks.compatibility.django_1_6_0 # NOQA
|
import django.core.checks.compatibility.django_1_6_0 # NOQA
|
||||||
|
@ -14,5 +14,5 @@ __all__ = [
|
||||||
'CheckMessage',
|
'CheckMessage',
|
||||||
'Debug', 'Info', 'Warning', 'Error', 'Critical',
|
'Debug', 'Info', 'Warning', 'Error', 'Critical',
|
||||||
'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL',
|
'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL',
|
||||||
'register', 'run_checks', 'tag_exists',
|
'register', 'run_checks', 'tag_exists', 'Tags',
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,10 +3,10 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
|
||||||
from .. import Warning, register
|
from .. import Warning, register, Tags
|
||||||
|
|
||||||
|
|
||||||
@register('compatibility')
|
@register(Tags.compatibility)
|
||||||
def check_1_6_compatibility(**kwargs):
|
def check_1_6_compatibility(**kwargs):
|
||||||
errors = []
|
errors = []
|
||||||
errors.extend(_check_test_runner(**kwargs))
|
errors.extend(_check_test_runner(**kwargs))
|
||||||
|
|
|
@ -6,10 +6,10 @@ import types
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
|
||||||
from . import Error, register
|
from . import Error, Tags, register
|
||||||
|
|
||||||
|
|
||||||
@register('models')
|
@register(Tags.models)
|
||||||
def check_all_models(app_configs=None, **kwargs):
|
def check_all_models(app_configs=None, **kwargs):
|
||||||
errors = [model.check(**kwargs)
|
errors = [model.check(**kwargs)
|
||||||
for model in apps.get_models()
|
for model in apps.get_models()
|
||||||
|
@ -17,7 +17,7 @@ def check_all_models(app_configs=None, **kwargs):
|
||||||
return list(chain(*errors))
|
return list(chain(*errors))
|
||||||
|
|
||||||
|
|
||||||
@register('models', 'signals')
|
@register(Tags.models, Tags.signals)
|
||||||
def check_model_signals(app_configs=None, **kwargs):
|
def check_model_signals(app_configs=None, **kwargs):
|
||||||
"""Ensure lazily referenced model signals senders are installed."""
|
"""Ensure lazily referenced model signals senders are installed."""
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
|
@ -6,6 +6,16 @@ from itertools import chain
|
||||||
from django.utils.itercompat import is_iterable
|
from django.utils.itercompat import is_iterable
|
||||||
|
|
||||||
|
|
||||||
|
class Tags(object):
|
||||||
|
"""
|
||||||
|
Built-in tags for internal checks.
|
||||||
|
"""
|
||||||
|
admin = 'admin'
|
||||||
|
compatibility = 'compatibility'
|
||||||
|
models = 'models'
|
||||||
|
signals = 'signals'
|
||||||
|
|
||||||
|
|
||||||
class CheckRegistry(object):
|
class CheckRegistry(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
Loading…
Reference in New Issue