def post(self): body = request.json if not body or not body["guild_id"] or not body["guild_id_snowflake"]: raise exceptions.MissingRequiredInformation() body["guild_id"] = str(body["guild_id"]) guild = Guild(**body) db.add(guild) current_app.logger.debug( "The guild {0} has been created successfully.".format(guild.id)) return guild.get_api_dict(), 201
def post(self, tournament_id): body = request.json if not body or not body["name"]: raise exceptions.MissingRequiredInformation() if "tournament_id" in body: del body["tournament_id"] bracket = Bracket(**body, tournament_id=tournament_id) db.add(bracket) current_app.logger.debug( "The bracket {0} has been created successfully.".format( bracket.id)) return bracket.get_api_dict(), 201
def post(self, tournament_id): body = request.json if not body or not body["match_id"]: raise exceptions.MissingRequiredInformation() if "tournament_id" in body: del body["tournament_id"] allowed_reschedule = AllowedReschedule(**body, tournament_id=tournament_id) db.add(allowed_reschedule) current_app.logger.debug( "The allowed reschedule {0} for match id {1} has been created successfully." .format(allowed_reschedule.id, allowed_reschedule.match_id)) return allowed_reschedule.get_api_dict(), 201
def post(self): body = request.json if not body or not body["discord_id"] or not body[ "discord_id_snowflake"]: raise exceptions.MissingRequiredInformation() body["discord_id"] = str(body["discord_id"]) if "osu_name_hash" in body: body["osu_name_hash"] = body["osu_name_hash"].casefold() user = User(**body) db.add(user) current_app.logger.debug( "The user {0} has been created successfully.".format(user.id)) return user.get_api_dict(), 201
def post(self): body = request.json if (not body or not body["guild_id"] or not body["guild_id_snowflake"] or not body["name"] or not body["acronym"]): raise exceptions.MissingRequiredInformation() body["guild_id"] = str(body["guild_id"]) tournament = Tournament(**body) db.add(tournament) bracket = Bracket(tournament_id=tournament.id, name=tournament.name) db.add(bracket) tournament.current_bracket_id = bracket.id db.update(tournament) current_app.logger.debug( "The tournament {0} has been created successfully.".format( tournament.id)) return get_tournament_data(tournament, True), 201
def post(self, tournament_id, bracket_id): bracket = (db.query(Bracket).where( Bracket.tournament_id == tournament_id).where( Bracket.id == bracket_id).first()) if not bracket: raise exceptions.NotFound() body = request.json if not body or not body["spreadsheet_id"]: raise exceptions.MissingRequiredInformation() body["spreadsheet_id"] = spreadsheet_api.extract_spreadsheet_id( body["spreadsheet_id"]) spreadsheet = QualifiersSpreadsheet(**body) db.add(spreadsheet) bracket.qualifiers_spreadsheet_id = spreadsheet.id db.update(bracket) current_app.logger.debug( "The qualifiers spreadsheet {0} for the bracket {1} has been created successfully." .format(spreadsheet.id, bracket_id)) return spreadsheet.get_api_dict(), 201
def store_token(data): token = None session_token = request.headers.get("Authorization") if session_token: token = db.query(Token).where( Token.session_token == session_token).first() if not token: token = Token() token.discord_user_id = get_user_id(data["access_token"]) session_token = str(uuid.uuid4()) token.session_token = session_token token.expiry_date = str(int(time.time()) + 2592000) db.add(token) token.access_token = data["access_token"] token.token_type = "user" token.access_token_expiry_date = str(int(time.time()) + data["expires_in"]) token.refresh_token = data["refresh_token"] token.scope = data["scope"] db.update(token) current_app.logger.debug( "A token has successfully been created/updated for the user {0}". format(token.discord_user_id)) return session_token