Ejemplo n.º 1
0
def modify_team():
    if login.user_id == 0:
        return redirect("/")
    if login.is_admin(login.user_id()):
        return render_template("adminpage.html")
    flash("Ei admin-oikeutta")
    return redirect("/")
Ejemplo n.º 2
0
def delete_message():
    if login.user_id == 0:
        return redirect("/")
    if login.is_admin(login.user_id()):
        id = request.form["message_id"]
        messages.delete_message(id)
        return render_template("adminpage.html")
    flash("Ei admin-oikeutta")
    return redirect("/")
Ejemplo n.º 3
0
def delete_team():
    if login.user_id == 0:
        return redirect("/")
    if login.is_admin(login.user_id()):
        team = request.form["team"].lower()
        teams.delete_team(team)
        return render_template("adminpage.html")
    flash("Ei admin-oikeutta")
    return redirect("/")
Ejemplo n.º 4
0
def add_rating(match_id):
    if request.method == "GET":
        return redirect("/")
    if request.method == "POST":
        rating = request.form["rating"]
        ratings.add_rating(login.user_id(), match_id, rating)
        list = matches.refresh_match_page(match_id)
        return render_template("matchpage.html",
                               match=list[0],
                               messages=list[1])
Ejemplo n.º 5
0
def delete_match():
    if request.method == "GET":
        return redirect("/")
    if login.user_id == 0:
        return redirect("/")
    if login.is_admin(login.user_id()):
        match_id = request.form["match_id"]
        matches.delete_match(match_id)
        return render_template("adminpage.html")
    flash("Ei admin-oikeutta")
    return redirect("/")
Ejemplo n.º 6
0
def modify_match():
    if request.method == "GET":
        return redirect("/")
    if login.user_id == 0:
        return redirect("/")
    if login.is_admin(login.user_id()):
        match_id = request.form["match_id"]
        home_points = request.form["home_points"]
        away_points = request.form["away_points"]
        matches.match_modify(match_id, home_points, away_points)
        return render_template("adminpage.html")
    flash("Ei admin-oikeutta")
    return redirect("/")
Ejemplo n.º 7
0
def modify_team_users():
    if request.method == "GET":
        return redirect("/")
    if login.user_id == 0:
        return redirect("/")
    if login.is_admin(login.user_id()):
        team = request.form["team"].lower()
        username1 = request.form["username1"].lower()
        username2 = request.form["username2"].lower()
        teams.modify_players(username1, username2, team)
        return render_template("adminpage.html")
    flash("Ei admin-oikeutta")
    return redirect("/")
Ejemplo n.º 8
0
def send_message(match_id, message):
    #adding a message to a match by id
    userid = login.user_id()
    if userid == 0 or len(message) < 1 or len(message) > 500:
        flash("Viestin lähetys epäonnistui")
        return
    pieces = str.split(message)
    for piece in pieces:
        if len(piece) > 25:
            flash("Lyhennä sanoja, max pituus 25 merkkiä")
            return
    sql = "INSERT INTO Messages (user_id, match_id, message, date) \
        VALUES (:userid,:match_id, :message, NOW())"
    db.session.execute(sql, {"userid":userid, "match_id":match_id, "message":message})
    db.session.commit()
    flash("Kommentti lisätty")
    del session["message"]
    return