41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from django.contrib.auth.decorators import login_required
|
|
from django.shortcuts import render
|
|
from django.utils import timezone
|
|
from django.utils.decorators import method_decorator
|
|
from django.views.generic import TemplateView
|
|
from oauth2_provider.contrib.rest_framework import IsAuthenticatedOrTokenHasScope
|
|
from rest_framework import generics
|
|
from rest_framework.exceptions import APIException, ErrorDetail
|
|
from rest_framework.permissions import AllowAny
|
|
from rest_framework.response import Response
|
|
from rest_framework.views import APIView
|
|
|
|
from apps.core.decorators import service_availability
|
|
from utils.exceptions import ServiceUnavailable
|
|
|
|
|
|
# Create your views here.
|
|
@method_decorator(login_required, name='dispatch')
|
|
class HomeView(TemplateView):
|
|
template_name = 'core/home.html'
|
|
|
|
|
|
class StatusView(APIView):
|
|
permission_classes = [AllowAny]
|
|
|
|
@service_availability('status')
|
|
def get(self, request, format=None):
|
|
|
|
data = {
|
|
"status": "ok",
|
|
}
|
|
return Response(data)
|
|
|
|
|
|
class HealthcheckView(APIView):
|
|
permission_classes = [AllowAny]
|
|
def get(self, request, format=None):
|
|
data = {
|
|
"is_healthy": True
|
|
}
|
|
return Response(data)
|