Example #1
0
 def cancel(self, request, *args, **kwargs):
     serializer = LikeSerializerForCancel(
         data=request.data,
         context={'request': request},
     )
     if not serializer.is_valid():
         return Response(
             {
                 'message': 'Please check input',
                 'errors': serializer.errors,
             },
             status=status.HTTP_400_BAD_REQUEST)
     serializer.cancel()
     return Response({'success': True}, status=status.HTTP_200_OK)
Example #2
0
 def cancel(self, request, *args, **kwargs):
     '''
     method use for unliking a tweet/comment
     /api/likes/cancel
     '''
     serializer = LikeSerializerForCancel(
         data=request.data,
         context={'request': request},
     )
     if not serializer.is_valid():
         return Response({
             "success": False,
             "errors": serializer.errors,
         },
                         status=HTTP_400_BAD_REQUEST)
     serializer.cancel()
     return Response({'success': True}, status=HTTP_200_OK)
Example #3
0
 def cancel(self, request):
     serializer = LikeSerializerForCancel(
         data=request.data,
         context={'request': request},
     )
     if not serializer.is_valid():
         return Response({
             'success': False,
             'error': serializer.errors,
         },
                         status=status.HTTP_400_BAD_REQUEST)
     deleted = serializer.cancel()
     return Response({
         'success': True,
         'deleted': deleted,
     },
                     status=status.HTTP_200_OK)