Commit b176c9c8 authored by Rafal's avatar Rafal

add api filter

parent a16e3ac6
......@@ -5,6 +5,7 @@ import rest_framework
from rest_framework.response import Response
from app.API.models import API, APIType
from app.API.serializers import APISerializer, APITypeSerializer
from app.User.models import UserAPI
class APIViewSet(viewsets.ModelViewSet):
......@@ -27,6 +28,16 @@ class APIViewSet(viewsets.ModelViewSet):
api = mod.API(request)
return HttpResponse(api.execute(function), content_type="application/json")
def get_queryset(self):
queryset = API.objects.all()
username = self.request.query_params.get('only_new', None)
if username is not None:
user_api = UserAPI.objects.all()
user_api = [api.api for api in user_api]
queryset = [api for api in queryset if api not in user_api]
return queryset
class APITypeViewSet(viewsets.ModelViewSet):
"""
API for articles
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment