Beispiel #1
0
def log_out():
    flash("Hate to see you leave")
    if login.is_admin(session["user_id"]):
        del session["admin"]
    del session["user_id"]
    del session["username"]
    return redirect("/")
Beispiel #2
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("/")
Beispiel #3
0
def articulos_new():
    global nombre_fichero
    from models import Articulos, Categorias
    from login import is_admin

    if not is_admin():
        abort(404)
        return render_template('404.html')

    form = formArticulo()
    categorias = [(c.id, c.nombre) for c in Categorias.query.all()[1:]]
    form.CategoriaId.choices = categorias

    if form.validate_on_submit():
        try:
            f = form.photo.data
            nombre_fichero = secure_filename(f.filename)

            upload = request.files["photo"]
            storage.child('images/' + nombre_fichero).put(upload)
        except:
            nombre_fichero = ""

        imglink = storage.child('images/' + nombre_fichero).get_url(None)
        art = Articulos()
        form.populate_obj(art)
        art.image = imglink
        current_db_session = db.session.object_session(art)
        db.session.add(art)
        db.session.commit()
        return redirect(url_for("admintab"))

    else:
        return render_template("upload.html", form=form)
Beispiel #4
0
def articulos_delete(id):
    from models import Articulos
    from login import is_admin

    art = Articulos.query.get(id)

    if art is None:
        return "<h1>No existe el archivo</h2>"

    if not is_admin():
        return render_template('404.html')

    form = formBnB()

    if form.validate_on_submit():
        if form.borrar.data:
            if art.image != "":
                os.remove(app.root_path + "/static/img/" + art.image)
            else:
                form.borrar.data(art)
    current_db_session = db.session.merge(art)
    db.session.delete(current_db_session)
    db.session.commit()
    return redirect(url_for("admintab"))
    return render_template("articulos_delete.html", form=form, art=art)
Beispiel #5
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("/")
Beispiel #6
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("/")
Beispiel #7
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("/")
Beispiel #8
0
 def get(self):
     need_tag = self.request.get('tag', 'ALL')
     tag_values = set()
     for note in NoteManager.getNotes():
         for tag in note.getTags():
             tag_values.add(tag)
     template_values = {
         'is_admin': is_admin(),
         'tag_values': tag_values,
         'need_tag': need_tag,
     }
     self.response.write(load_template('list_notes2.html', template_values))
Beispiel #9
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("/")
Beispiel #10
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("/")