Commit c970018f authored by Tim Graham's avatar Tim Graham
Browse files

Removed Django 1.7 MIDDLEWARE_CLASSES upgrade check.

parent 5b75b019
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ from .messages import (CheckMessage,
from .registry import register, run_checks, tag_exists, Tags

# Import these to force registration of checks
import django.core.checks.compatibility.django_1_7_0  # NOQA
import django.core.checks.model_checks  # NOQA
import django.core.checks.security.base  # NOQA
import django.core.checks.security.csrf  # NOQA
+0 −0

Empty file deleted.

+0 −36
Original line number Diff line number Diff line
from __future__ import unicode_literals

from .. import Tags, Warning, register


@register(Tags.compatibility)
def check_1_7_compatibility(**kwargs):
    errors = []
    errors.extend(_check_middleware_classes(**kwargs))
    return errors


def _check_middleware_classes(app_configs=None, **kwargs):
    """
    Checks if the user has *not* overridden the ``MIDDLEWARE_CLASSES`` setting &
    warns them about the global default changes.
    """
    from django.conf import settings

    # MIDDLEWARE_CLASSES is overridden by default by startproject. If users
    # have removed this override then we'll warn them about the default changes.
    if not settings.is_overridden('MIDDLEWARE_CLASSES'):
        return [
            Warning(
                "MIDDLEWARE_CLASSES is not set.",
                hint=("Django 1.7 changed the global defaults for the MIDDLEWARE_CLASSES. "
                      "django.contrib.sessions.middleware.SessionMiddleware, "
                      "django.contrib.auth.middleware.AuthenticationMiddleware, and "
                      "django.contrib.messages.middleware.MessageMiddleware were removed from the defaults. "
                      "If your project needs these middleware then you should configure this setting."),
                obj=None,
                id='1_7.W001',
            )
        ]
    else:
        return []
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ that might occur as a result of a version upgrade.
  ``django.contrib.auth.middleware.AuthenticationMiddleware``, and
  ``django.contrib.messages.middleware.MessageMiddleware`` were removed from
  the defaults. If your project needs these middleware then you should
  configure this setting.
  configure this setting. *This check was removed in Django 1.9*.

Admin
-----
+0 −37
Original line number Diff line number Diff line
@@ -4,11 +4,8 @@ from __future__ import unicode_literals
import sys

from django.apps import apps
from django.conf import settings
from django.core import checks
from django.core.checks import Error, Warning
from django.core.checks.compatibility.django_1_7_0 import \
    check_1_7_compatibility
from django.core.checks.registry import CheckRegistry
from django.core.management import call_command
from django.core.management.base import CommandError
@@ -112,40 +109,6 @@ class MessageTests(TestCase):
        self.assertEqual(force_text(e), expected)


class Django_1_7_0_CompatibilityChecks(TestCase):

    @override_settings(MIDDLEWARE_CLASSES=['django.contrib.sessions.middleware.SessionMiddleware'])
    def test_middleware_classes_overridden(self):
        errors = check_1_7_compatibility()
        self.assertEqual(errors, [])

    def test_middleware_classes_not_set_explicitly(self):
        # If MIDDLEWARE_CLASSES was set explicitly, temporarily pretend it wasn't
        middleware_classes_overridden = False
        if 'MIDDLEWARE_CLASSES' in settings._wrapped._explicit_settings:
            middleware_classes_overridden = True
            settings._wrapped._explicit_settings.remove('MIDDLEWARE_CLASSES')
        try:
            errors = check_1_7_compatibility()
            expected = [
                checks.Warning(
                    "MIDDLEWARE_CLASSES is not set.",
                    hint=("Django 1.7 changed the global defaults for the MIDDLEWARE_CLASSES. "
                          "django.contrib.sessions.middleware.SessionMiddleware, "
                          "django.contrib.auth.middleware.AuthenticationMiddleware, and "
                          "django.contrib.messages.middleware.MessageMiddleware were removed from the defaults. "
                          "If your project needs these middleware then you should configure this setting."),
                    obj=None,
                    id='1_7.W001',
                )
            ]
            self.assertEqual(errors, expected)
        finally:
            # Restore settings value
            if middleware_classes_overridden:
                settings._wrapped._explicit_settings.add('MIDDLEWARE_CLASSES')


def simple_system_check(**kwargs):
    simple_system_check.kwargs = kwargs
    return []
Loading