.
This commit is contained in:
@@ -172,6 +172,8 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
return False
|
return False
|
||||||
if self.app_name == "longs" and not user.groups.filter(name='long_checker').exists():
|
if self.app_name == "longs" and not user.groups.filter(name='long_checker').exists():
|
||||||
return False
|
return False
|
||||||
|
if self.app_name == "physics" and not user.groups.filter(name='physic_checker').exists():
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,19 @@ import plotly.express as px
|
|||||||
|
|
||||||
from generic.views import ExamViews
|
from generic.views import ExamViews
|
||||||
|
|
||||||
|
from rest_framework import viewsets, permissions
|
||||||
|
from rest_framework.pagination import PageNumberPagination
|
||||||
|
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
|
|
||||||
|
class AuthorOrCheckerRequiredMixin(object):
|
||||||
|
def get_object(self, *args, **kwargs):
|
||||||
|
obj = super().get_object(*args, **kwargs)
|
||||||
|
if self.request.user.groups.filter(name="physics_checker").exists():
|
||||||
|
return obj
|
||||||
|
if self.request.user not in obj.author.all():
|
||||||
|
raise PermissionDenied() # or Http404
|
||||||
|
return obj
|
||||||
|
|
||||||
def question_list(request):
|
def question_list(request):
|
||||||
questions = Question.objects.all()
|
questions = Question.objects.all()
|
||||||
|
|||||||
Reference in New Issue
Block a user