Предварительная сохраняшка
This commit is contained in:
1 parent
ba33de3d77
commit
17f35a0f5d
875 files changed
+146196
-124
No files matched your search
@@ -0,0 +1,63 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework.generics import ListAPIView
|
||||
# Create your views here.
|
||||
from .models import *
|
||||
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||
from rest_framework.response import Response
|
||||
from .serializers import *
|
||||
from userauth.models import *
|
||||
|
||||
class LinkAPIView(ListAPIView):
|
||||
permission_classes = (AllowAny,)
|
||||
serializer_class = LinkSerializer
|
||||
|
||||
|
||||
def get(self, request):
|
||||
|
||||
queryset = Links.objects.all().order_by('order')
|
||||
serializer = self.serializer_class(queryset, many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
class NewsAPIView(ListAPIView):
|
||||
permission_classes = (AllowAny,)
|
||||
serializer_class = NewsSerializer
|
||||
|
||||
|
||||
def get(self, request):
|
||||
|
||||
queryset = News.objects.all().order_by('cdate')[:10]
|
||||
# serializer = self.serializer_class(queryset, many=True)
|
||||
# print(serializer.data)
|
||||
result = []
|
||||
for x in queryset:
|
||||
|
||||
a=model_to_dict(x)
|
||||
a['link']= str(x.link.url)
|
||||
a['show'] = False
|
||||
a['author'] = model_to_dict(DictEmployee.objects.using('user_directory').get(login=x.author.username))
|
||||
result.append(a)
|
||||
|
||||
return Response(result)
|
||||
|
||||
class CarouselsAPIView(ListAPIView):
|
||||
permission_classes = (AllowAny,)
|
||||
serializer_class = CarouselsSerializer
|
||||
|
||||
|
||||
def get(self, request):
|
||||
|
||||
queryset = Carousels.objects.filter(published=True).order_by('order')
|
||||
# serializer = self.serializer_class(queryset, many=True)
|
||||
# print(serializer.data)
|
||||
result = []
|
||||
for x in queryset:
|
||||
|
||||
a=model_to_dict(x)
|
||||
a['link']= str(x.link.url)
|
||||
a['show'] = False
|
||||
a['author'] = model_to_dict(DictEmployee.objects.using('user_directory').get(login=x.author.username))
|
||||
result.append(a)
|
||||
|
||||
return Response(result)
|
||||
|
||||
Reference in new issue
Block a user