Exemplo n.º 1
0
 def _get_gamesession(cls, params):
     """ Get the user id and project version id for this game session """
     try:
         session = cls.game_session_list.get_session(
             params['gameSessionId'])
         if session is None:
             raise InvalidGameSession()
         return session
     except (KeyError, TypeError):
         raise InvalidGameSession()
Exemplo n.º 2
0
 def from_dict(cls, gamesession):
     game = get_game_by_slug(gamesession['game'])
     # remove any sessions pointing at old games / users
     if game:
         return GameSession(game, get_user(gamesession['user']),
                            gamesession.get('gameSessionId', None),
                            gamesession.get('created', None))
     else:
         raise InvalidGameSession('No gamesession with that id')
Exemplo n.º 3
0
 def to_dict(self):
     try:
         return {
             'gameSessionId': self.gamesession_id,
             'user': self.user.username,
             'game': str(self.game.slug),
             'created': self.created
         }
     except AttributeError:
         raise InvalidGameSession()
Exemplo n.º 4
0
 def _get_gamesession(cls, params):
     """ Get the user id and project version id for this game session """
     try:
         session = cls.game_session_list.get_session(
             params['gameSessionId'])
     except KeyError:
         raise BadRequest('Request is missing gameSessionId parameter')
     if session is None:
         raise InvalidGameSession('No gamesession with that id')
     return session