summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2019-10-05 08:30:04 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2019-10-19 17:14:34 (GMT)
commita14ced4d18ce868b9b2d7a37ce4d937c734f09e6 (patch)
treec400f4bbbd04150fd2441c221e940d925aa514a9
parent21ce5ece537b99d54dfdf4d7f605abedfa22ff7d (diff)
downloadhobo-master.zip
hobo-master.tar.gz
hobo-master.tar.bz2
dj22: use user.is_authenticated as a boolean (#36708)HEADmaster
-rw-r--r--hobo/context_processors.py2
-rw-r--r--hobo/rest_authentication.py9
-rw-r--r--hobo/views.py2
-rw-r--r--tests_authentic/test_rest_authentication.py2
4 files changed, 7 insertions, 8 deletions
diff --git a/hobo/context_processors.py b/hobo/context_processors.py
index b0acdf7..436cbdd 100644
--- a/hobo/context_processors.py
+++ b/hobo/context_processors.py
@@ -160,7 +160,7 @@ def portal_agent_url(request):
if 'authentic2' in settings.INSTALLED_APPS:
portal_agents = [x for x in settings.KNOWN_SERVICES.get('combo', {}).values()
if x.get('is-portal-agent')]
- if len(portal_agents) > 1 and request.user and request.user.is_authenticated() and request.user.ou_id:
+ if len(portal_agents) > 1 and request.user and request.user.is_authenticated and request.user.ou_id:
ou_slug = request.user.ou.slug
for portal_agent in portal_agents:
variables = portal_agent.get('variables') or {}
diff --git a/hobo/rest_authentication.py b/hobo/rest_authentication.py
index 765e440..88c544a 100644
--- a/hobo/rest_authentication.py
+++ b/hobo/rest_authentication.py
@@ -18,8 +18,8 @@ except ImportError:
class AnonymousAuthenticServiceUser(AnonymousUser):
'''This virtual user hold permissions for other publik services'''
- def is_authenticated(self):
- return True
+ is_authenticated = True
+ is_anonymous = True
def has_perm(self, perm_or_perms, obj=None):
return True
@@ -41,9 +41,8 @@ class AnonymousAuthenticServiceUser(AnonymousUser):
class AnonymousAdminServiceUser(AnonymousUser):
'''This virtual user hold permissions for other publik services'''
is_staff = True
-
- def is_authenticated(self):
- return True
+ is_authenticated = True
+ is_anonymous = True
def __unicode__(self):
return 'Publik Service Admin'
diff --git a/hobo/views.py b/hobo/views.py
index 63fb584..8f59ac6 100644
--- a/hobo/views.py
+++ b/hobo/views.py
@@ -19,7 +19,7 @@ from .environment.utils import Zone, get_installed_services
from .forms import HoboForm, HoboUpdateForm, get_tenant_model
def is_superuser(u):
- if not u.is_authenticated():
+ if not u.is_authenticated:
return False
if not u.is_superuser:
raise PermissionDenied
diff --git a/tests_authentic/test_rest_authentication.py b/tests_authentic/test_rest_authentication.py
index e059ea3..2b15bf4 100644
--- a/tests_authentic/test_rest_authentication.py
+++ b/tests_authentic/test_rest_authentication.py
@@ -46,7 +46,7 @@ def test_publik_authentication(tenant, settings):
assert isinstance(result, tuple)
assert len(result) == 2
assert result[0].__class__ is rest_authentication.AnonymousAdminServiceUser
- assert result[0].is_authenticated()
+ assert result[0].is_authenticated
assert result[0].is_staff
assert result[1] is None