Example #1
0
 def post(self,request,pk):
   profile = util.get_profile_given_user_id(request.user.id)
   player = profile.players.filter(accepted=False).filter(id=pk)
   if(not player):
     return Response("No player for this user with that id", status=status.HTTP_400_BAD_REQUEST)
   else:
     player = player[0]
     player.accepted = True
     player.save()
     return Response("Accepted", status=status.HTTP_200_OK)
Example #2
0
 def get(self, request):
   profile = util.get_profile_given_user_id(request.user.id)
   games = util.get_games_for_profile(profile)
   serializer = GameSerializer(games)
   return Response(serializer.data)
Example #3
0
 def get(self, request):
   profile = util.get_profile_given_user_id(request.user.id)
   players = profile.players.filter(accepted=False)
   serializer = PlayerSerializer(players)
   return Response(serializer.data, status=status.HTTP_200_OK)
Example #4
0
 def get(self, request):
   profile = ProfileSerializer(util.get_profile_given_user_id(request.user.id))
   return Response(profile.data, status=status.HTTP_200_OK)
Example #5
0
 def delete(self, request):
   profile = util.get_profile_given_user_id(request.user.id)
   profile.delete()
   return Response(status=status.HTTP_NO_CONTENT)