.
This commit is contained in:
+10
-7
@@ -14,7 +14,7 @@ from django.core.exceptions import PermissionDenied, FieldError
|
||||
from django.http import Http404, JsonResponse
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
|
||||
|
||||
|
||||
from django.utils.decorators import method_decorator
|
||||
@@ -66,12 +66,15 @@ import plotly.express as px
|
||||
from django.db.models import Prefetch
|
||||
|
||||
|
||||
class CidManagerRequiredMixin(object):
|
||||
def get_object(self, *args, **kwargs):
|
||||
obj = super().get_object(*args, **kwargs)
|
||||
if self.request.user.groups.filter(name="cid_user_manager").exists():
|
||||
return obj
|
||||
raise PermissionDenied() # or Http404
|
||||
class CidManagerRequiredMixin(UserPassesTestMixin):
|
||||
|
||||
def test_func(self):
|
||||
return self.request.user.groups.filter(name="cid_user_manager").exists()
|
||||
# def get_object(self, *args, **kwargs):
|
||||
# obj = super().get_object(*args, **kwargs)
|
||||
# if self.request.user.groups.filter(name="cid_user_manager").exists():
|
||||
# return obj
|
||||
# raise PermissionDenied() # or Http404
|
||||
|
||||
|
||||
def normaliseRapidsScore(score):
|
||||
|
||||
Reference in New Issue
Block a user