34 lines
1.8 KiB
Python
34 lines
1.8 KiB
Python
from django.shortcuts import render
|
|
from .serializers import *
|
|
from .models import *
|
|
from rest_framework.views import APIView
|
|
from rest_framework.response import Response
|
|
|
|
class CalendarEventsAPIView(APIView):
|
|
|
|
def get(self, request):
|
|
return Response('ku')
|
|
|
|
def post(self, request):
|
|
|
|
namecalendar, created = CalendarEventsName.objects.update_or_create(name=request.data['participants'],
|
|
defaults = {'name':request.data['participants'], 'author_id': self.request.user.id})
|
|
# print(self.request.user.id, '111111111111111111111111111111111111111111111111')
|
|
|
|
for cal in request.data['calendar']:
|
|
CalendarEvents.objects.update_or_create(calendarname_id=namecalendar.pk,
|
|
name = cal['summary'],
|
|
author_id = self.request.user.id,
|
|
defaults = {'name': cal['summary'],
|
|
'description': cal['description'],
|
|
'cdate':cal['start'],
|
|
'enddate': cal['end'],
|
|
'author_id': self.request.user.id,
|
|
'place': cal['location'],
|
|
'calendarname_id': namecalendar.pk
|
|
})
|
|
# print(cal['summary'],'1---------------------------')
|
|
# print(cal['description'],'2---------------------------')
|
|
return Response('ru')
|
|
# Create your views here.
|