Exemple #1
0
def get_rounds():
    if request.method == "GET":
        drinks = dbc.get_all_drinks()
        teams = dbc.get_all_teams()
        people = dbc.get_all_people(drinks, teams)
        rounds = dbc.get_all_rounds(people, teams)
        orders = dbc.get_all_orders(drinks, people, rounds)
        return jsonify([round.to_json() for round in list(rounds.values())])
Exemple #2
0
def new_member():
    if request.method == "GET":
        drinks = dbc.get_all_drinks()
        teams = dbc.get_all_teams()
        return render_template('add_member.html',
                               title="Add Member",
                               drinks=drinks,
                               teams=teams)

    if request.method == "POST":
        drinks = dbc.get_all_drinks()
        teams = dbc.get_all_teams()
        first_name = request.form.get("first_name")
        second_name = request.form.get("second_name")
        preference = drinks[int(request.form.get("drink_id"))]
        team = teams[int(request.form.get("team_id"))]
        add_person(first_name, second_name, preference, team)
        return teams_page()
Exemple #3
0
def get_teams():
    if request.method == "GET":
        teams = dbc.get_all_teams()
        return jsonify([team.to_json() for team in list(teams.values())])

    elif request.method == "POST":
        team_name = request.form.get("team_name")
        team_location = request.form.get("team_location")
        add_team(team_name, team_location)
Exemple #4
0
def new_round():
    if request.method == "GET":
        drinks = dbc.get_all_drinks()
        teams = dbc.get_all_teams()
        people = dbc.get_all_people(drinks, teams)
        return render_template('new_round.html',
                               title="New round",
                               people=people)

    if request.method == "POST":
        result = request.form.to_dict()
        person_id = int(result["person_id"])
        drinks = dbc.get_all_drinks()
        teams = dbc.get_all_teams()
        people = dbc.get_all_people(drinks, teams)
        maker = people[person_id]
        add_round(maker, maker.team)
        return rounds_page()
Exemple #5
0
def view_team():
    if request.method == "GET":
        return teams_page()

    if request.method == "POST":
        drinks = dbc.get_all_drinks()
        teams = dbc.get_all_teams()
        people = dbc.get_all_people(drinks, teams)

        result = request.form.to_dict()
        team_id = int(result["team_id"])
        team_name = teams[team_id].name

        return render_template('view_team.html',
                               team_id=team_id,
                               team_name=team_name,
                               people=people)
Exemple #6
0
def view_orders():
    if request.method == "POST":
        result = request.form.to_dict()
        round_id = int(result["round_id"])

        drinks = dbc.get_all_drinks()
        teams = dbc.get_all_teams()
        people = dbc.get_all_people(drinks, teams)
        rounds = dbc.get_all_rounds(people, teams)
        orders = dbc.get_all_orders(drinks, people, rounds)

        round_title = rounds[round_id].__str__()

        return render_template('view_orders.html',
                               title="Orders",
                               orders=orders,
                               round_id=round_id,
                               round_title=round_title)
Exemple #7
0
def teams_page():
    teams = dbc.get_all_teams()
    return render_template('teams.html', title="People", teams=teams)
Exemple #8
0
def get_person():
    if request.method == "GET":
        drinks = dbc.get_all_drinks()
        teams = dbc.get_all_teams()
        people = dbc.get_all_people(drinks, teams)
        return jsonify([person.to_json() for person in list(people.values())])
Exemple #9
0
def get_teams():
    teams = dbc.get_all_teams()
    return jsonify([team.to_json() for team in list(teams.values())])