Restrict ExamCollectionList to authenticated users and filter by current user as author
This commit is contained in:
+7
-2
@@ -5734,7 +5734,7 @@ class SupervisorList(CidManagerRequiredMixin, SingleTableMixin, FilterView):
|
||||
filterset_class = SupervisorFilter
|
||||
|
||||
|
||||
class ExamCollectionList(AuthorRequiredMixin, ListView):
|
||||
class ExamCollectionList(ListView):
|
||||
model = ExamCollection
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -5742,7 +5742,12 @@ class ExamCollectionList(AuthorRequiredMixin, ListView):
|
||||
# allow toggling whether archived collections are included via ?show_archived=1
|
||||
show_archived = self.request.GET.get("show_archived")
|
||||
|
||||
base_qs = ExamCollection.objects.all()
|
||||
# If user is anonymous return empty set; otherwise limit to collections
|
||||
# where the current user is listed as an author.
|
||||
if not self.request.user.is_authenticated:
|
||||
return ExamCollection.objects.none()
|
||||
|
||||
base_qs = ExamCollection.objects.filter(author=self.request.user)
|
||||
if not show_archived:
|
||||
base_qs = base_qs.filter(archive=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user