Browse Source

Add project filter to ProjectViewSet

pull/10/head
Hironsan 6 years ago
parent
commit
90aec25f70
2 changed files with 9 additions and 1 deletions
  1. BIN
      app/db.sqlite3
  2. 10
      app/server/views.py

BIN
app/db.sqlite3

10
app/server/views.py

@ -107,6 +107,12 @@ class ProjectViewSet(viewsets.ModelViewSet):
pagination_class = None
permission_classes = (IsAuthenticated, IsAdminUserAndWriteOnly)
def get_queryset(self):
user = self.request.user
queryset = self.queryset.filter(users__id__contains=user.id)
return queryset
@action(methods=['get'], detail=True)
def progress(self, request, pk=None):
project = self.get_object()
@ -193,8 +199,10 @@ class AnnotationsAPI(generics.ListCreateAPIView):
return self.serializer_class
def get_queryset(self):
project_id = self.kwargs['project_id']
project = get_object_or_404(Project, pk=project_id)
doc_id = self.kwargs['doc_id']
document = get_object_or_404(Document, pk=doc_id)
document = get_object_or_404(Document, pk=doc_id, project=project)
self.queryset = Factory.get_annotations_by_doc(document)
return self.queryset

Loading…
Cancel
Save