misc: restore usage of CallableTrue (#41391)

This reverts commit ca5168f203, as it is
still required by djangorestframework 3.4 used in stretch.
This commit is contained in:
Frédéric Péters 2020-04-06 20:56:47 +02:00
parent 8b230ae47a
commit 9dc31f3386
1 changed files with 20 additions and 4 deletions

View File

@ -8,6 +8,10 @@ from django.contrib.auth import get_user_model
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.db.models.fields import FieldDoesNotExist
try:
from django.utils.deprecation import CallableTrue
except ImportError:
CallableTrue = True
from django.utils.module_loading import import_string
try:
@ -18,8 +22,14 @@ except ImportError:
class AnonymousAuthenticServiceUser(AnonymousUser):
'''This virtual user hold permissions for other publik services'''
is_anonymous = True
is_authenticated = True
@property
def is_anonymous(self):
return CallableTrue
@property
def is_authenticated(self):
return CallableTrue
def has_perm(self, perm_or_perms, obj=None):
return True
@ -41,8 +51,14 @@ class AnonymousAuthenticServiceUser(AnonymousUser):
class AnonymousAdminServiceUser(AnonymousUser):
'''This virtual user hold permissions for other publik services'''
is_staff = True
is_anonymous = True
is_authenticated = True
@property
def is_anonymous(self):
return CallableTrue
@property
def is_authenticated(self):
return CallableTrue
def __unicode__(self):
return 'Publik Service Admin'