Exemple #1
0
def post_round():
    content = request.get_json()
    maker_json = content["maker"]
    maker = get_person_from_JSON(maker_json)
    new_round = Round(maker)
    for order in get_orders_from_JSON(content["orders"]):
        new_round.add_order(order[0], order[1])
    db.save_round(new_round, db.get_all_people_as_people(), db.get_all_drinks_as_drinks(),
                  db.get_all_rounds_as_rounds())
    return jsonify(new_round)
Exemple #2
0
def create_round():
    if request.method == "GET":
        return render_template('add_round.html', title="Create Form", people=db.get_all_people_as_people(),
                               drinks=db.get_all_drinks_as_drinks(),rounds=db.get_all_rounds_as_rounds())
    elif request.method == "POST":
        maker = request.form.get("maker")
        new_round = Round(maker)
        people = db.get_all_people_as_people()
        for index,person in enumerate(people):
            if request.form.get(f"checkbox{index}"):
                new_round.add_order(person)
        db.save_round(new_round,people,db.get_all_drinks_as_drinks(),db.get_all_rounds_as_rounds())
        return render_template("return_posted.html", title="Posted",object=new_round)
Exemple #3
0
def generateRoundObjects(roundData, episodeNumber):
    roundObjects = list()
    roundCounter = 1
    remainingRoundData = roundData
    while True:
        currRound = remainingRoundData[:5]
        if currRound[1] == "" or roundCounter >= 6:
            break
        tempRoundObj = Round(currRound[1], currRound[0], currRound[3], roundCounter, episodeNumber, currRound[2])
        tempRoundObj.playerAdvanced = determineWinLossAtRoundObjectGeneration(currRound[4])
        roundObjects.append(tempRoundObj)

        roundCounter += 1
        remainingRoundData = remainingRoundData[3:]
    return roundObjects
Exemple #4
0
def get_all_rounds_as_rounds():
    round_list = []
    get_rounds_sql = """
        SELECT p.first_name, p.last_name, d.name
        FROM people p
        JOIN rounds r ON r.maker_id = p.person_id
        JOIN drinks as d on d.drink_id = p.drink_id
        ORDER BY r.round_id;
        """
    rounds = cursor_select(get_rounds_sql)
    for round in rounds:
        round_list.append(Round(Person(round[0], round[1], round[2])))

    get_roundOrders_sql = """
        SELECT ro.round_id, p.first_name, p.last_name, dr.name,  d.name
        FROM rounds r
        JOIN roundOrders as ro on r.round_id = ro.round_id
        JOIN people as p on p.person_id = ro.person_id
        JOIN drinks as dr on dr.drink_id = p.drink_id
        JOIN drinks as d on d.drink_id = ro.drink_id
        ORDER BY ro.round_id;
        """

    roundOrders = cursor_select(get_roundOrders_sql)

    for order in roundOrders:
        round_index = order[0] - 1
        person = Person(order[1], order[2], order[3])
        drink = Drink(order[4])
        round_list[round_index].add_order(person, drink)
    return round_list
Exemple #5
0
def start_round(people):
    show_people(people)

    maker_id_prompt = "Please enter the UID of the round's maker: "
    maker_id = inputHandler.get_input_as_integer(
        inputHandler.get_input(maker_id_prompt))
    people_id_prompt = "Please enter the ids of the people who want a drink, separated by comma: "
    people_id_list = inputHandler.get_input_as_list(
        inputHandler.get_input(people_id_prompt), ",")

    people_list = []
    for people_id in people_id_list:
        people_list.append(get_person(people, int(people_id)))
    new_round = Round(get_person(people, maker_id), people_list)
    new_round.print_round()
    fileHandler.pickle_variable("store/", "lastround", new_round)
Exemple #6
0
def start_round(people, drinks):
    show_people(people)

    maker_id_prompt = "Please enter the UID of the round's maker: "
    maker_id = inputHandler.get_input_as_integer(
        inputHandler.get_input(maker_id_prompt))
    # people_id_prompt = "Please enter the ids of the people who want a drink, separated by comma: "
    # people_id_list = inputHandler.get_input_as_list(inputHandler.get_input(people_id_prompt), ",")
    new_round = Round(get_person(people, maker_id))
    add_orders_to_round(people, drinks, new_round)
def parse_round_element(round_element):
    edition_round = Round()
    match_elements = round_element.find_all("div", {"class": "match"})
    if len(match_elements) == 0:
        raise Exception("No matches found in round")

    for match_element in match_elements:
        match_id = get_match_id(match_element)
        if match_id is not None:
            edition_round.match_ids.append(match_id)
    return edition_round
Exemple #8
0
def start_round_with_names(people):
    show_people(people)

    maker_id_prompt = "Please enter the UID of the round's maker: "
    maker_id = inputHandler.get_input_as_integer(
        inputHandler.get_input(maker_id_prompt))
    people_name_prompt = "Please enter the names of the people who want a drink, separated by comma: "
    people_name_list = inputHandler.get_input_as_list(
        inputHandler.get_input(people_name_prompt), ",")

    people_list = []
    for person_name in people_name_list:
        person_index = find_person(people, person_name)
        if person_index > -1:
            people_list.append(get_person(people, person_index))
        else:
            print(
                f"{person_name} is not a name in the list, did you include their surname?"
            )
            return
    new_round = Round(get_person(people, maker_id), people_list)
    new_round.print_round()
    fileHandler.pickle_variable("store/", "lastround", new_round)