def new_order(): 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) return render_template('new_order.html', title="Create Order", people=people, drinks=drinks, rounds=rounds) elif request.method == "POST": drinks = dbc.get_all_drinks() teams = dbc.get_all_teams() people = dbc.get_all_people(drinks, teams) rounds = dbc.get_all_rounds(people, teams) round_key = request.form.get("round_id") person_key = request.form.get("person_id") drink_key = request.form.get("drink_id") notes = request.form.get("notes") person = people[int(person_key)] drink = drinks[int(drink_key)] round = rounds[int(round_key)] add_order(person, drink, round, notes) return rounds_page()
def rounds_page(): 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 render_template('rounds.html', title="Rounds", rounds=rounds)
def get_rounds(): 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())])
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)