Beispiel #1
0
    def free_busy(self, request, calendar_id):
        decoded_token = decode_token(request.META)

        from_date = request.data('from_date', now() - timedelta(days=14))
        to_date = request.data('to_date', now() + timedelta(days=14))

        event = Event()
        serializer = EventSerializer(event.free_busy(decoded_token['user_id'],
                                                     from_date, to_date),
                                     many=True)
        event.close()

        return Response(serializer.data, status=status.HTTP_200_OK)
Beispiel #2
0
    def free_busy(self, request, client_id, user_id):
        if not self.is_valid(client_id, user_id):
            return Response({"message": "Not found."},
                            status=status.HTTP_404_NOT_FOUND)

        from_date = request.data.get('from_date',
                                     (now() - timedelta(days=14)).isoformat())
        to_date = request.data.get('to_date',
                                   (now() + timedelta(days=14)).isoformat())

        event = Event()
        serializer = EventSerializer(event.free_busy(int(user_id), from_date,
                                                     to_date),
                                     many=True)
        event.close()

        return Response(serializer.data, status=status.HTTP_200_OK)