From 09cca1906f43aab48a2f81208a1610ee7d795395 Mon Sep 17 00:00:00 2001 From: Ross Date: Fri, 23 Apr 2021 10:13:57 +0100 Subject: [PATCH] . --- rapids/views.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rapids/views.py b/rapids/views.py index 71dee54b..cbea9ac1 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -915,9 +915,20 @@ class QuestionDelete(AuthorOrCheckerRequiredMixin, DeleteView): RapidExamViews = ExamViews(Exam, Rapid, "rapids", "rapid", loadJsonAnswer) class ExamViewSet(viewsets.ModelViewSet): - queryset = Exam.objects.all().order_by('name') + #queryset = Exam.objects.all().order_by('name') serializer_class = ExamSerializer + def get_queryset(self): + """ + This view should return a list of all the purchases + for the currently authenticated user. + """ + user = self.request.user + if user.groups.filter(name="rapid_checker").exists(): + return Exam.objects.all() + + return Purchase.objects.filter(author__id=user.id) + class ExamCreate(LoginRequiredMixin, CreateView): model = Exam form_class = ExamForm