[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:
Tim Graham 2014-04-10 08:45:48 -04:00
parent 0b43308e2d
commit 32e6237450
7 changed files with 20 additions and 10 deletions

View File

@ -11,7 +11,7 @@ class SimpleAdminConfig(AppConfig):
verbose_name = _("Administration")
def ready(self):
checks.register('admin')(check_admin_app)
checks.register(checks.Tags.admin)(check_admin_app)
class AdminConfig(SimpleAdminConfig):

View File

@ -10,4 +10,4 @@ class AuthConfig(AppConfig):
verbose_name = _("Authentication and Authorization")
def ready(self):
checks.register('models')(check_user_model)
checks.register(checks.Tags.models)(check_user_model)

View File

@ -9,4 +9,4 @@ class ContentTypesConfig(AppConfig):
verbose_name = _("Content Types")
def ready(self):
checks.register('models')(check_generic_foreign_keys)
checks.register(checks.Tags.models)(check_generic_foreign_keys)

View File

@ -4,7 +4,7 @@ from __future__ import unicode_literals
from .messages import (CheckMessage,
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 django.core.checks.compatibility.django_1_6_0 # NOQA
@ -14,5 +14,5 @@ __all__ = [
'CheckMessage',
'Debug', 'Info', 'Warning', 'Error', 'Critical',
'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL',
'register', 'run_checks', 'tag_exists',
'register', 'run_checks', 'tag_exists', 'Tags',
]

View File

@ -3,10 +3,10 @@ from __future__ import unicode_literals
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):
errors = []
errors.extend(_check_test_runner(**kwargs))

View File

@ -6,10 +6,10 @@ import types
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):
errors = [model.check(**kwargs)
for model in apps.get_models()
@ -17,7 +17,7 @@ def check_all_models(app_configs=None, **kwargs):
return list(chain(*errors))
@register('models', 'signals')
@register(Tags.models, Tags.signals)
def check_model_signals(app_configs=None, **kwargs):
"""Ensure lazily referenced model signals senders are installed."""
from django.db import models

View File

@ -6,6 +6,16 @@ from itertools import chain
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):
def __init__(self):