Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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