From cc53f217f6122151bcae131a42da8f8887f8560d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 15 Apr 2021 15:14:44 +0200 Subject: new valid and util module, more function decorators --- api/game/info.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'api/game/info.py') diff --git a/api/game/info.py b/api/game/info.py index 71fed2e..73c31ff 100644 --- a/api/game/info.py +++ b/api/game/info.py @@ -4,6 +4,7 @@ from db import cursor from user.info import format_user from rating import outcome from ruleset import resolve_ruleset +import valid def format_game(game_id, user_id=None): @@ -56,14 +57,6 @@ def format_game(game_id, user_id=None): } -# check if game_id exists in database -def valid_game_id(game_id): - query = cursor.execute( - "select game_id from games where game_id = ?", [game_id] - ).fetchone() - return bool(query) - - game_info = Blueprint('game_info', __name__) @@ -79,7 +72,7 @@ def index(): token = request.cookies.get("token") or "" if token: user_id = token_login(token) - if not valid_game_id(game_id): return "", 403 + if not valid.game_id(game_id): return "", 403 return format_game(game_id, user_id), 200 -- cgit v1.2.3