def post(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) free_dict = {} if serializer.validated_data["sync"]: from api.utils.common import make_credentials make_credentials(request=request, user=self.request.auth.user, freebusy=True) for day in serializer.validated_data["list_of_days"]: free_dict[str(day)] = get_user_freebusy_list( request=self.request, user=self.request.auth.user, day=day, sync_before=False, convert_free=True ) return Response(free_dict, status=status.HTTP_201_CREATED)
def get(self, request, *args, **kwargs): current_user = self.request.auth.user items = make_credentials(request=self.request, user=current_user, freebusy=True) if "error" in items: return Response(items, status=status.HTTP_400_BAD_REQUEST) else: return Response(items, status=status.HTTP_200_OK)
def patch(self, request, *args, **kwargs): current_user = self.request.auth.user service = make_credentials(request=request, user=current_user, to_google=True) dates = self.check_dates_from_request(data=request.data, partial=True) if type(dates) is Response: return dates filtered_data = self.cut_dates_from_request(data=request.data) serializer = EventPatchSerializer(data=filtered_data) return self.make_API_call(request, serializer, service)
def post(self, request, *args, **kwargs): current_user = self.request.auth.user service = make_credentials(request=request, user=current_user, to_google=True) # get start and end from request.data and validate it with Date / DateTime serializers dates = self.check_dates_from_request(data=request.data) if type(dates) is Response: return dates # make filtered request.data without start and end to validate it filtered_data = self.cut_dates_from_request(data=request.data) # validating filtered_data via serializer serializer = EventCreateSerializer(data=filtered_data) return self.make_API_call(request, serializer, service)
def get(self, request, *args, **kwargs): current_user = self.request.auth.user service = make_credentials(request=request, user=current_user, to_google=True) return self.make_api_call(service)
def delete(self, request, *args, **kwargs): current_user = self.request.auth.user service = make_credentials(request=request, user=current_user, to_google=True) serializer = EventDeleteSerializer(data=request.data) return self.make_API_call(request, serializer, service)