添加逻辑支持设置常用人

main
RogerWork 10 months ago
parent b7b6cfcea3
commit f43c65e4e4
  1. 1
      update/urls.py
  2. 15
      update/views.py

@ -26,6 +26,7 @@ router.register('user', views.CinemaUserViewSet, 'cinema_user')
urlpatterns = [
# path('cinema/search/', views.CinemaSearchAPIView.as_view()),
path('', include(router.urls)),
path('update_user/', update_user),
path('get_git_version/', get_git_version),
path('get_operation_cmd/', get_operation_cmd),
# re_path(r'^cinema/search/ip/(?P<ip>[0-9.]*?)/version/(?P<version>[\S]*?)/$', views.CinemaSearchAPIView.as_view())

@ -1,3 +1,5 @@
import json
from django.http import JsonResponse
from django.db.models import Q
from rest_framework import viewsets, permissions, status, filters
@ -10,6 +12,7 @@ from rest_framework.response import Response
from rest_framework_extensions.cache.mixins import CacheResponseMixin
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from django.views.decorators.csrf import csrf_exempt
from django_filters.rest_framework import DjangoFilterBackend
from django.core.cache import cache
from update.utils.get_version import GetVersion
@ -32,7 +35,7 @@ class CinemaViewSet(CacheResponseMixin, viewsets.ModelViewSet):
"""
queryset = Cinema.objects.all()
serializer_class = CinemaSerializer
permission_classes = (permissions.IsAuthenticated,)
# permission_classes = (permissions.IsAuthenticated,)
filter_backends = (filters.SearchFilter, DjangoFilterBackend, OrderingFilter)
ordering_fields = ('ip',)
search_fields = ('sys_ver',)
@ -64,6 +67,14 @@ class CinemaUserViewSet(CacheResponseMixin, viewsets.ModelViewSet):
# serializer = CinemaSerializer(instance=query_data, many=True)
# return Response(serializer.data, status=status.HTTP_200_OK)
@csrf_exempt
def update_user(request, *args, **kwargs):
cinema_id = request.GET.dict().get('id')
user = json.loads(request.body).get('user', '暂无')
result = Cinema.objects.filter(id=cinema_id).update(user=user)
return JsonResponse({'result': 'success'} if result == 1 else {'result': 'fail'})
def get_git_version(request):
git_util = GitUtil()
git_ver = git_util.get_short_version()
@ -154,4 +165,4 @@ def update_cine(request):
# 传输客户端
client_release = ClientUtil()
client_release.client_process(cinema_ip, short_release)
return JsonResponse({'result': 'success'})
return JsonResponse({'result': 'success'})

Loading…
Cancel
Save