Browse Source

Integrate random order to example list api

pull/2261/head
Hironsan 1 year ago
parent
commit
7dc58a50ad
2 changed files with 7 additions and 2 deletions
  1. 6
      backend/examples/views/example.py
  2. 3
      frontend/components/example/FormAssignment.vue

6
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)

3
frontend/components/example/FormAssignment.vue

@ -18,7 +18,8 @@
hide-details
></v-select>
{{ 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.
</v-col>
</v-row>
<v-row>

Loading…
Cancel
Save