|
|
@ -1,6 +1,10 @@ |
|
|
|
from rest_framework import viewsets, permissions |
|
|
|
from django.http import JsonResponse |
|
|
|
|
|
|
|
from django.db.models import Q |
|
|
|
|
|
|
|
from rest_framework import viewsets, permissions, status |
|
|
|
from update.models import Cinema |
|
|
|
from update.models import Cinema |
|
|
|
from update.serializers import CinemaSerializer |
|
|
|
from update.serializers import CinemaSerializer |
|
|
|
|
|
|
|
from rest_framework.views import APIView |
|
|
|
|
|
|
|
from rest_framework.response import Response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CinemaViewSet(viewsets.ModelViewSet): |
|
|
|
class CinemaViewSet(viewsets.ModelViewSet): |
|
|
@ -15,3 +19,13 @@ class CinemaViewSet(viewsets.ModelViewSet): |
|
|
|
queryset = Cinema.objects.all() |
|
|
|
queryset = Cinema.objects.all() |
|
|
|
serializer_class = CinemaSerializer |
|
|
|
serializer_class = CinemaSerializer |
|
|
|
permission_classes = (permissions.IsAuthenticated,) |
|
|
|
permission_classes = (permissions.IsAuthenticated,) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CinemaSearchAPIView(APIView): |
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
|
|
|
query_params = request.query_params.dict() |
|
|
|
|
|
|
|
print(query_params) |
|
|
|
|
|
|
|
query_data = Cinema.objects.filter( |
|
|
|
|
|
|
|
Q(ip__contains=query_params.get('ip')) & Q(sys_ver__icontains=query_params.get('version'))) |
|
|
|
|
|
|
|
serializer = CinemaSerializer(instance=query_data, many=True) |
|
|
|
|
|
|
|
return Response(serializer.data, status=status.HTTP_200_OK) |
|
|
|