Esempio n. 1
0
 def get(self, request: Request, *args, **kwargs):
     gameId = kwargs.get('id')
     try:
         gamelog = GameService(gameId).get_gamelog()
         return Response(
             json.loads(gamelog.as_json(), object_pairs_hook=OrderedDict))
     except Gameinfo.DoesNotExist:
         raise NotFound(detail=f'No game found for gameId {gameId}')
Esempio n. 2
0
 def post(self, request, *args, **kwargs):
     try:
         data = request.data
         game_service = GameService(data.get('gameId'))
         gamelog = game_service.create_gamelog(data.get('team'),
                                               data.get('event'),
                                               request.user,
                                               data.get('half'))
         game_service.update_score(gamelog)
         return Response(json.loads(gamelog.as_json(),
                                    object_pairs_hook=OrderedDict),
                         status=HTTPStatus.CREATED)
     except Gameinfo.DoesNotExist:
         raise NotFound(
             detail=
             f'Could not create team logs ... gameId {request.data.get("gameId")} not found'
         )
     except Team.DoesNotExist:
         raise NotFound(
             detail=
             f'Could not create team logs ... team {request.data.get("team")} not found'
         )
Esempio n. 3
0
 def put(self, request, *args, **kwargs):
     game_service = GameService(kwargs.get('pk'))
     game_service.update_team_in_possesion(request.data.get('team'))
     return Response()