.
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 Http404, JsonResponse
|
||||||
from django.http import HttpResponseRedirect, HttpResponse
|
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
|
from django.utils.decorators import method_decorator
|
||||||
@@ -66,12 +66,15 @@ import plotly.express as px
|
|||||||
from django.db.models import Prefetch
|
from django.db.models import Prefetch
|
||||||
|
|
||||||
|
|
||||||
class CidManagerRequiredMixin(object):
|
class CidManagerRequiredMixin(UserPassesTestMixin):
|
||||||
def get_object(self, *args, **kwargs):
|
|
||||||
obj = super().get_object(*args, **kwargs)
|
def test_func(self):
|
||||||
if self.request.user.groups.filter(name="cid_user_manager").exists():
|
return self.request.user.groups.filter(name="cid_user_manager").exists()
|
||||||
return obj
|
# def get_object(self, *args, **kwargs):
|
||||||
raise PermissionDenied() # or Http404
|
# 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):
|
def normaliseRapidsScore(score):
|
||||||
|
|||||||
Reference in New Issue
Block a user