30 lines
838 B
Python
30 lines
838 B
Python
from rest_framework import status
|
|
from rest_framework.views import APIView
|
|
from rest_framework.response import Response
|
|
from api.utils.decorators import handle_exceptions
|
|
|
|
from api.main.serializers import FAQMainSerializer, NewsMainSerializer
|
|
from sitemanagement.models import FAQ, News
|
|
|
|
class FAQView(APIView):
|
|
@handle_exceptions
|
|
def get(self, request):
|
|
|
|
faqs = FAQ.objects.all()
|
|
|
|
data = {
|
|
'faqs': FAQMainSerializer(faqs, many=True).data
|
|
}
|
|
|
|
return Response(data, status=status.HTTP_200_OK)
|
|
class NewsView(APIView):
|
|
@handle_exceptions
|
|
def get(self, request):
|
|
|
|
news = News.objects.all()
|
|
|
|
data = {
|
|
'news': NewsMainSerializer(news, many=True).data
|
|
}
|
|
|
|
return Response(data, status=status.HTTP_200_OK) |