31 lines
988 B
Python
31 lines
988 B
Python
from django.shortcuts import render
|
|
from .serializers import *
|
|
from .models import *
|
|
from rest_framework.views import APIView
|
|
from rest_framework.generics import ListAPIView
|
|
from rest_framework.response import Response
|
|
import json
|
|
from django.db.models.functions import TruncYear
|
|
from userauth.serializers import *
|
|
|
|
|
|
|
|
|
|
class ExclusionDatesAPIView(APIView):
|
|
def get(self, request):
|
|
year = self.request.query_params.get('year', datetime.now().year)
|
|
exclude = ExclusionDates.objects.filter(exclusiondate__year=year)
|
|
months = {}
|
|
for i in range(1,12):
|
|
months[i] = exclude.filter(exclusiondate__month=i).values_list("exclusiondate")
|
|
return Response({year:months})
|
|
|
|
|
|
class GetCalendars(APIView):
|
|
def get(self, request):
|
|
|
|
calendars = Calendar.objects.filter(get_user__patrcipant_calendar__id=request.user.user.id)
|
|
return Response(CalendarsSerializer(calendars,context={'request': request},many=True).data)
|
|
|
|
|