From 8bc442e7715f56cf108a35025493af90687e33ee Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 22 Jul 2008 03:05:40 +0000 Subject: [PATCH] Fixed #7304 -- Gave AnonymousUser a has_perms() method, which it was lacking git-svn-id: http://code.djangoproject.com/svn/django/trunk@8044 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/auth/models.py | 3 +++ tests/regressiontests/auth_backends/tests.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index a0ed4f366f..3ea184a7f8 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -358,6 +358,9 @@ class AnonymousUser(object): def has_perm(self, perm): return False + def has_perms(self, perm_list): + return False + def has_module_perms(self, module): return False diff --git a/tests/regressiontests/auth_backends/tests.py b/tests/regressiontests/auth_backends/tests.py index 3ec2a059ad..d22f0bf939 100644 --- a/tests/regressiontests/auth_backends/tests.py +++ b/tests/regressiontests/auth_backends/tests.py @@ -4,7 +4,7 @@ except NameError: from sets import Set as set # Python 2.3 fallback __test__ = {'API_TESTS': """ ->>> from django.contrib.auth.models import User, Group, Permission +>>> from django.contrib.auth.models import User, Group, Permission, AnonymousUser >>> from django.contrib.contenttypes.models import ContentType # No Permissions assigned yet, should return False except for superuser @@ -69,4 +69,10 @@ True True >>> user.has_perms(['auth.test3', 'auth.test_group']) True + +>>> user = AnonymousUser() +>>> user.has_perm('test') +False +>>> user.has_perms(['auth.test2', 'auth.test3']) +False """}