.
This commit is contained in:
+10
-1
@@ -66,6 +66,15 @@ import plotly.express as px
|
|||||||
from django.db.models import Prefetch
|
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
|
||||||
|
if self.request.user not in obj.author.all():
|
||||||
|
raise PermissionDenied() # or Http404
|
||||||
|
return obj
|
||||||
|
|
||||||
def normaliseRapidsScore(score):
|
def normaliseRapidsScore(score):
|
||||||
if score == 49:
|
if score == 49:
|
||||||
return 4.5
|
return 4.5
|
||||||
@@ -1264,7 +1273,7 @@ class ExaminationAutocomplete(autocomplete.Select2QuerySetView):
|
|||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
||||||
class CidUserView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
class CidUserView(CidManagerRequiredMixin, SingleTableMixin, FilterView):
|
||||||
model = CidUser
|
model = CidUser
|
||||||
table_class = CidUserTable
|
table_class = CidUserTable
|
||||||
template_name = "generic/cid_view.html"
|
template_name = "generic/cid_view.html"
|
||||||
|
|||||||
Reference in New Issue
Block a user