misc: use is_authenticated as a straight boolean value (#41633)
This commit is contained in:
parent
2d5a06fd56
commit
ea66c6c782
|
@ -41,7 +41,7 @@ from .visualization.utils import Visualization as VisuUtil
|
||||||
|
|
||||||
class AuthorizationMixin(object):
|
class AuthorizationMixin(object):
|
||||||
def authorize(self, request):
|
def authorize(self, request):
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated:
|
||||||
if not request.user.is_superuser:
|
if not request.user.is_superuser:
|
||||||
raise PermissionDenied(_('You must be superuser'))
|
raise PermissionDenied(_('You must be superuser'))
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -184,7 +184,7 @@ class VisualizationView(views.AuthorizationMixin, CubeDisplayMixin, DetailView):
|
||||||
|
|
||||||
class SignatureAuthorizationMixin(views.AuthorizationMixin):
|
class SignatureAuthorizationMixin(views.AuthorizationMixin):
|
||||||
def authorize(self, request):
|
def authorize(self, request):
|
||||||
if request.user.is_authenticated() and request.user.is_superuser:
|
if request.user.is_authenticated and request.user.is_superuser:
|
||||||
return True
|
return True
|
||||||
if 'signature' in request.GET:
|
if 'signature' in request.GET:
|
||||||
signature = request.path + settings.SECRET_KEY
|
signature = request.path + settings.SECRET_KEY
|
||||||
|
@ -230,7 +230,7 @@ class VisualizationsJSONView(MultipleObjectMixin, View):
|
||||||
model = models.Visualization
|
model = models.Visualization
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
if not request.user.is_authenticated() or not request.user.is_superuser:
|
if not request.user.is_authenticated or not request.user.is_superuser:
|
||||||
known_services = getattr(settings, 'KNOWN_SERVICES', [])
|
known_services = getattr(settings, 'KNOWN_SERVICES', [])
|
||||||
if known_services:
|
if known_services:
|
||||||
key = None
|
key = None
|
||||||
|
|
Loading…
Reference in New Issue