Example #1
0
def drink_round_handler():
    if 'username' in session and teams.current_team_id:
        if request.method == "GET":
            drinks_round = Round()
            read_round(0, False, int(request.args["team_id"]), drinks_round)
            team_members = TeamMembers()
            read_team_member(int(request.args["team_id"]), team_members, 0)
            brewer_options = [team_member.to_json() for team_member in team_members.team_members.values()]
            drinks = Drinks()
            read_drink(int(request.args["team_id"]), drinks, 0)
            drink_options = [drink.to_json() for drink in drinks.drinks.values()]
            return render_template("drinks_round.html", round_page="active", data=drinks_round.to_json(), team_id=request.args["team_id"], round_id=drinks_round.id, show_if_round=("" if drinks_round.id else "none"), brewer_options=brewer_options, drink_options=drink_options)
        elif request.method == "POST":
            round_id = None if request.form["id"] == "None" or int(request.form["id"]) == 0 else int(request.form["id"])
            if request.form["clear-order"] == "true":
                new_id = create_round(round_id, int(request.form["roundBrewer"]), int(request.args["team_id"]), 0)
                if request.form["prepopulate"] == "true":
                    drinks_round = Round()
                    team_members = TeamMembers()
                    read_team_member(int(request.args["team_id"]), team_members, 0)
                    for person in team_members.team_members.values():
                        drinks_round.add_drink(person.preference, person)
                    update_order_records(drinks_round, new_id)
            else:
                update_brewer(round_id, int(request.form["roundBrewer"]))
            return redirect("/drinks-round?team_id=" + str(request.args["team_id"]))
        elif request.method == "DELETE":
            clear_order_records(int(request.args["id"]))
            return request.args
    else:
        return redirect("/login")
Example #2
0
def team_member_handler():
    if 'username' in session and teams.current_team_id:
        if request.method == "GET":
            team_members = TeamMembers()
            read_team_member(int(request.args["team_id"]), team_members, 0)
            drinks = Drinks()
            read_drink(int(request.args["team_id"]), drinks, 0)
            drink_options = [
                drink.to_json() for drink in drinks.drinks.values()
            ]
            return render_template(
                "team_members.html",
                team_member_page="active",
                data=[
                    team_member.to_json()
                    for team_member in team_members.team_members.values()
                ],
                team_id=request.args["team_id"],
                drink_options=drink_options)
        elif request.method == "POST":
            if int(request.form["id"]) == 0:
                append_team_member(0, request.form["teamMemberName"],
                                   int(request.form["teamMemberPreference"]),
                                   int(request.args["team_id"]))
            else:
                update_team_member(int(request.form["id"]),
                                   request.form["teamMemberName"],
                                   int(request.form["teamMemberPreference"]))
            return redirect("/team-members?team_id=" +
                            str(request.args["team_id"]))
    else:
        return redirect("/login")
Example #3
0
def drink_handler():
    if 'username' in session and teams.current_team_id:
        if request.method == "GET":
            drinks = Drinks()
            read_drink(int(request.args["team_id"]), drinks, 0)
            return render_template("drinks.html", drink_page="active", data=[drink.to_json() for drink in drinks.drinks.values()], team_id=request.args["team_id"])
        elif request.method == "POST":
            if int(request.form["id"]) == 0:
                append_drink(0, request.form["drinkName"], int(request.args["team_id"]))
            else:
                update_drink(int(request.form["id"]), request.form["drinkName"])
            return redirect("/drinks?team_id=" + str(request.args["team_id"]))
    else:
        return redirect("/login")
Example #4
0
def run_app():
    any_orders = False
    item_type = 0
    drinks = Drinks()
    team_members = TeamMembers()
    teams = Teams()
    drinks_round = Round()

    os.system("printf '\e[8;100;200t'")
    arguments = sys.argv
    if len(arguments) == 2 and arguments[1] == "mib":
        item_type = 1
    read_team(teams)
    any_orders = login(False, any_orders, item_type, teams, drinks,
                       team_members, drinks_round)
    show_menu(any_orders, item_type, teams, drinks, team_members, drinks_round)