Add Django backend, Next.js frontend, and deploy templates
This commit is contained in:
1 parent
fc0c991335
commit
e9cd22d36f
93 files changed
+7840
-1
No files matched your search
@@ -0,0 +1,70 @@
|
||||
from rest_framework import generics
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from .models import ContactMessage, Doctor, Document, Page, Service, SiteSettings
|
||||
from .serializers import (
|
||||
ContactMessageSerializer,
|
||||
DoctorSerializer,
|
||||
DocumentSerializer,
|
||||
PageSerializer,
|
||||
ServiceSerializer,
|
||||
SiteSettingsSerializer,
|
||||
)
|
||||
|
||||
|
||||
class HomeAPIView(APIView):
|
||||
def get(self, request):
|
||||
settings_obj = SiteSettings.objects.order_by("id").first()
|
||||
data = {
|
||||
"site": SiteSettingsSerializer(settings_obj).data if settings_obj else None,
|
||||
"pages": PageSerializer(Page.objects.filter(is_published=True)[:6], many=True).data,
|
||||
"services": ServiceSerializer(Service.objects.all()[:6], many=True).data,
|
||||
"doctors": DoctorSerializer(Doctor.objects.all(), many=True).data,
|
||||
"documents": DocumentSerializer(Document.objects.all()[:4], many=True).data,
|
||||
}
|
||||
return Response(data)
|
||||
|
||||
|
||||
class SiteSettingsAPIView(generics.RetrieveAPIView):
|
||||
serializer_class = SiteSettingsSerializer
|
||||
|
||||
def get_object(self):
|
||||
return SiteSettings.objects.order_by("id").first()
|
||||
|
||||
|
||||
class PageListAPIView(generics.ListAPIView):
|
||||
serializer_class = PageSerializer
|
||||
queryset = Page.objects.filter(is_published=True)
|
||||
|
||||
|
||||
class PageDetailAPIView(generics.RetrieveAPIView):
|
||||
serializer_class = PageSerializer
|
||||
lookup_field = "slug"
|
||||
queryset = Page.objects.filter(is_published=True)
|
||||
|
||||
|
||||
class ServiceListAPIView(generics.ListAPIView):
|
||||
serializer_class = ServiceSerializer
|
||||
queryset = Service.objects.all()
|
||||
|
||||
|
||||
class ServiceDetailAPIView(generics.RetrieveAPIView):
|
||||
serializer_class = ServiceSerializer
|
||||
lookup_field = "slug"
|
||||
queryset = Service.objects.all()
|
||||
|
||||
|
||||
class DoctorListAPIView(generics.ListAPIView):
|
||||
serializer_class = DoctorSerializer
|
||||
queryset = Doctor.objects.all()
|
||||
|
||||
|
||||
class DocumentListAPIView(generics.ListAPIView):
|
||||
serializer_class = DocumentSerializer
|
||||
queryset = Document.objects.all()
|
||||
|
||||
|
||||
class ContactMessageCreateAPIView(generics.CreateAPIView):
|
||||
serializer_class = ContactMessageSerializer
|
||||
queryset = ContactMessage.objects.all()
|
||||
Reference in new issue
Block a user