Commit 1070c57b authored by Russell Keith-Magee's avatar Russell Keith-Magee
Browse files

Fixed #14436 -- Escalated 1.2 PendingDeprecationWarnings to...

Fixed #14436 -- Escalated 1.2 PendingDeprecationWarnings to DeprecationWarnings, and removed 1.1 deprecated code.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14138 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 5e5be2c4
Loading
Loading
Loading
Loading
+0 −75
Original line number Diff line number Diff line
@@ -456,81 +456,6 @@ class AdminSite(object):
            context_instance=context_instance
        )

    def root(self, request, url):
        """
        DEPRECATED. This function is the old way of handling URL resolution, and
        is deprecated in favor of real URL resolution -- see ``get_urls()``.

        This function still exists for backwards-compatibility; it will be
        removed in Django 1.3.
        """
        import warnings
        warnings.warn(
            "AdminSite.root() is deprecated; use include(admin.site.urls) instead.",
            DeprecationWarning
        )

        #
        # Again, remember that the following only exists for
        # backwards-compatibility. Any new URLs, changes to existing URLs, or
        # whatever need to be done up in get_urls(), above!
        #

        if request.method == 'GET' and not request.path.endswith('/'):
            return http.HttpResponseRedirect(request.path + '/')

        if settings.DEBUG:
            self.check_dependencies()

        # Figure out the admin base URL path and stash it for later use
        self.root_path = re.sub(re.escape(url) + '$', '', request.path)

        url = url.rstrip('/') # Trim trailing slash, if it exists.

        # The 'logout' view doesn't require that the person is logged in.
        if url == 'logout':
            return self.logout(request)

        # Check permission to continue or display login form.
        if not self.has_permission(request):
            return self.login(request)

        if url == '':
            return self.index(request)
        elif url == 'password_change':
            return self.password_change(request)
        elif url == 'password_change/done':
            return self.password_change_done(request)
        elif url == 'jsi18n':
            return self.i18n_javascript(request)
        # URLs starting with 'r/' are for the "View on site" links.
        elif url.startswith('r/'):
            from django.contrib.contenttypes.views import shortcut
            return shortcut(request, *url.split('/')[1:])
        else:
            if '/' in url:
                return self.model_page(request, *url.split('/', 2))
            else:
                return self.app_index(request, url)

        raise http.Http404('The requested admin page does not exist.')

    def model_page(self, request, app_label, model_name, rest_of_url=None):
        """
        DEPRECATED. This is the old way of handling a model view on the admin
        site; the new views should use get_urls(), above.
        """
        from django.db import models
        model = models.get_model(app_label, model_name)
        if model is None:
            raise http.Http404("App %r, model %r, not found." % (app_label, model_name))
        try:
            admin_obj = self._registry[model]
        except KeyError:
            raise http.Http404("This model exists but has not been registered with the admin site.")
        return admin_obj(request, rest_of_url)
    model_page = never_cache(model_page)

# This global object represents the default admin site, for the common case.
# You can instantiate AdminSite in your own code to create a custom admin site.
site = AdminSite()
+2 −2
Original line number Diff line number Diff line
@@ -22,12 +22,12 @@ def load_backend(path):
        raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
    if not hasattr(cls, "supports_object_permissions"):
        warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
             PendingDeprecationWarning)
             DeprecationWarning)
        cls.supports_object_permissions = False

    if not hasattr(cls, 'supports_anonymous_user'):
        warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
             PendingDeprecationWarning)
             DeprecationWarning)
        cls.supports_anonymous_user = False
    return cls()

+2 −2
Original line number Diff line number Diff line
@@ -380,7 +380,7 @@ class User(models.Model):
        import warnings
        warnings.warn('The user messaging API is deprecated. Please update'
                      ' your code to use the new messages framework.',
                      category=PendingDeprecationWarning)
                      category=DeprecationWarning)
        return self._message_set
    message_set = property(_get_message_set)

+6 −0
Original line number Diff line number Diff line
import warnings

from django.conf import settings
from django.contrib.auth.models import User, Group, Permission, AnonymousUser
from django.contrib.contenttypes.models import ContentType
@@ -152,9 +154,13 @@ class RowlevelBackendTest(TestCase):
        self.user1 = User.objects.create_user('test', 'test@example.com', 'test')
        self.user2 = User.objects.create_user('test2', 'test2@example.com', 'test')
        self.user3 = User.objects.create_user('test3', 'test3@example.com', 'test')
        warnings.filterwarnings('ignore', category=DeprecationWarning,
                                module='django.contrib.auth')

    def tearDown(self):
        settings.AUTHENTICATION_BACKENDS = self.curr_auth
        warnings.resetwarnings()
        warnings.simplefilter('ignore', PendingDeprecationWarning)

    def test_has_perm(self):
        self.assertEqual(self.user1.has_perm('perm', TestObj()), False)
+1 −1
Original line number Diff line number Diff line
@@ -3,5 +3,5 @@ from django.views.decorators.csrf import csrf_exempt, csrf_view_exempt, csrf_res

import warnings
warnings.warn("This import for CSRF functionality is deprecated.  Please use django.middleware.csrf for the middleware and django.views.decorators.csrf for decorators.",
              PendingDeprecationWarning
              DeprecationWarning
              )
Loading