From 7dc58a50ad5da02567367e0e7ec110794350686c Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 9 Aug 2023 14:00:54 +0900 Subject: [PATCH] Integrate random order to example list api --- backend/examples/views/example.py | 6 +++++- frontend/components/example/FormAssignment.vue | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/examples/views/example.py b/backend/examples/views/example.py index fa889b26..f5fe041a 100644 --- a/backend/examples/views/example.py +++ b/backend/examples/views/example.py @@ -28,7 +28,11 @@ class ExampleList(generics.ListCreateAPIView): member = get_object_or_404(Member, project=self.project, user=self.request.user) if member.is_admin(): return self.model.objects.filter(project=self.project) - return self.model.objects.filter(project=self.project, assignments__assignee=self.request.user) + + queryset = self.model.objects.filter(project=self.project, assignments__assignee=self.request.user) + if self.project.random_order: + queryset = queryset.order_by("assignments__id") + return queryset def perform_create(self, serializer): serializer.save(project=self.project) diff --git a/frontend/components/example/FormAssignment.vue b/frontend/components/example/FormAssignment.vue index e1aa8c3b..bffe65f6 100644 --- a/frontend/components/example/FormAssignment.vue +++ b/frontend/components/example/FormAssignment.vue @@ -18,7 +18,8 @@ hide-details > {{ strategies.find((strategy) => strategy.value === selectedStrategy)?.description }} - Note that assigning to an administrator does not make sense. + The project managers have access to all examples, regardless of whether they are + assigned or not.