|
|
@ -1,6 +1,8 @@ |
|
|
|
from django.http import JsonResponse |
|
|
|
from django.http import JsonResponse |
|
|
|
from django.db.models import Q |
|
|
|
from django.db.models import Q |
|
|
|
from rest_framework import viewsets, permissions, status, filters |
|
|
|
from rest_framework import viewsets, permissions, status, filters |
|
|
|
|
|
|
|
from rest_framework.filters import OrderingFilter |
|
|
|
|
|
|
|
|
|
|
|
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.views import APIView |
|
|
@ -27,16 +29,18 @@ class CinemaViewSet(CacheResponseMixin, viewsets.ModelViewSet): |
|
|
|
queryset = Cinema.objects.all() |
|
|
|
queryset = Cinema.objects.all() |
|
|
|
serializer_class = CinemaSerializer |
|
|
|
serializer_class = CinemaSerializer |
|
|
|
permission_classes = (permissions.IsAuthenticated,) |
|
|
|
permission_classes = (permissions.IsAuthenticated,) |
|
|
|
filter_backends = (filters.SearchFilter, DjangoFilterBackend) |
|
|
|
filter_backends = (filters.SearchFilter, DjangoFilterBackend, OrderingFilter) |
|
|
|
|
|
|
|
ordering_fields = ('ip', ) |
|
|
|
search_fields = ('sys_ver',) |
|
|
|
search_fields = ('sys_ver',) |
|
|
|
# filter_fields = ('ip',) |
|
|
|
# filter_fields = ('ip',) |
|
|
|
filterset_fields = ('ip',) |
|
|
|
filterset_fields = ('ip',) |
|
|
|
GetVersion().main_process() |
|
|
|
GetVersion().main_process() |
|
|
|
|
|
|
|
|
|
|
|
@action(methods=['get'], detail=False) |
|
|
|
@action(methods=['get'], detail=False) |
|
|
|
|
|
|
|
@method_decorator(cache_page(60 * 1)) |
|
|
|
def refresh(self, request, *args, **kwargs): |
|
|
|
def refresh(self, request, *args, **kwargs): |
|
|
|
GetVersion().main_process() |
|
|
|
GetVersion().main_process() |
|
|
|
queryset = Cinema.objects.all() |
|
|
|
queryset = Cinema.objects.all().order_by('ip') |
|
|
|
serializer = self.get_serializer(instance=queryset, many=True) |
|
|
|
serializer = self.get_serializer(instance=queryset, many=True) |
|
|
|
return Response(serializer.data) |
|
|
|
return Response(serializer.data) |
|
|
|
|
|
|
|
|
|
|
|