summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-12-31 11:46:40 -0500
committerTim Graham <timograham@gmail.com>2017-01-17 20:52:03 -0500
commiteba093e8b02989af1857b1915907ca0897f565ff (patch)
tree9168860253e3956ced80b9e639e8e1c36211057c /django
parentb70094f0408384993e149ffcfc86cc2d405308d1 (diff)
Refs #25847 -- Removed support for User.is_(anonymous|authenticated) as methods.
Per deprecation timeline.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/auth/base_user.py5
-rw-r--r--django/contrib/auth/models.py5
-rw-r--r--django/utils/deprecation.py43
3 files changed, 4 insertions, 49 deletions
diff --git a/django/contrib/auth/base_user.py b/django/contrib/auth/base_user.py
index 9ad5cde87f..104748ff69 100644
--- a/django/contrib/auth/base_user.py
+++ b/django/contrib/auth/base_user.py
@@ -12,7 +12,6 @@ from django.contrib.auth.hashers import (
)
from django.db import models
from django.utils.crypto import get_random_string, salted_hmac
-from django.utils.deprecation import CallableFalse, CallableTrue
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
@@ -91,7 +90,7 @@ class AbstractBaseUser(models.Model):
Always return False. This is a way of comparing User objects to
anonymous users.
"""
- return CallableFalse
+ return False
@property
def is_authenticated(self):
@@ -99,7 +98,7 @@ class AbstractBaseUser(models.Model):
Always return True. This is a way to tell if the user has been
authenticated in templates.
"""
- return CallableTrue
+ return True
def set_password(self, raw_password):
self.password = make_password(raw_password)
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index 6055526941..d91412eb5c 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -9,7 +9,6 @@ from django.core.mail import send_mail
from django.db import models
from django.db.models.manager import EmptyManager
from django.utils import six, timezone
-from django.utils.deprecation import CallableFalse, CallableTrue
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
@@ -443,11 +442,11 @@ class AnonymousUser(object):
@property
def is_anonymous(self):
- return CallableTrue
+ return True
@property
def is_authenticated(self):
- return CallableFalse
+ return False
def get_username(self):
return self.username
diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py
index 2963e60214..b862a161b2 100644
--- a/django/utils/deprecation.py
+++ b/django/utils/deprecation.py
@@ -84,49 +84,6 @@ class DeprecationInstanceCheck(type):
return super(DeprecationInstanceCheck, self).__instancecheck__(instance)
-class CallableBool:
- """
- An boolean-like object that is also callable for backwards compatibility.
- """
- do_not_call_in_templates = True
-
- def __init__(self, value):
- self.value = value
-
- def __bool__(self):
- return self.value
-
- def __call__(self):
- warnings.warn(
- "Using user.is_authenticated() and user.is_anonymous() as a method "
- "is deprecated. Remove the parentheses to use it as an attribute.",
- RemovedInDjango20Warning, stacklevel=2
- )
- return self.value
-
- def __nonzero__(self): # Python 2 compatibility
- return self.value
-
- def __repr__(self):
- return 'CallableBool(%r)' % self.value
-
- def __eq__(self, other):
- return self.value == other
-
- def __ne__(self, other):
- return self.value != other
-
- def __or__(self, other):
- return bool(self.value or other)
-
- def __hash__(self):
- return hash(self.value)
-
-
-CallableFalse = CallableBool(False)
-CallableTrue = CallableBool(True)
-
-
class MiddlewareMixin(object):
def __init__(self, get_response=None):
self.get_response = get_response