Пример #1
0
def user(name):
    try:
        user = sql.getUser(name)
    except sql.SQLError:
        abort(404)
    tasks = sorted(sql.getTasks(), key=lambda x: (x.categorie, x.points, x.level))
    return render_template("main.html",
                           view="user.html",
                           user=user,
                           tasks=tasks,
                           solved=sql.getSolved(user.login))
Пример #2
0
def admin_user():
    if not "admin" in session or not session["admin"]:
        abort(404)
    login = request.args.get("login", None)
    try:
        user = sql.getUser(login)
    except sql.SQLError:
        flash("No such user", "danger")
        return redirect(url_for('admin'))
    if request.method == 'POST':
        ret = doPost(user)
        if ret:
            return ret
    user = sql.getUser(login)
    tasks = sorted(sql.getTasks(), key=(lambda x : (x.categorie, x.points, x.level)))
    medals = json.loads(user.medals) if user.medals is not None else None
    csrf_token = uuid.uuid4()
    session['csrf_token'] = csrf_token
    return render_template("main.html", view="admin_user.html", user=user,
                           tasks=tasks, solved=sql.getSolved(user.login),
                           medals=medals, csrf_token=csrf_token)
Пример #3
0
def show_tasks():
    tasks = sorted(sql.getTasks(), key=lambda x: (x.categorie, x.points, x.level))
    return render_template("main.html", view="tasks.html",  tasks=tasks,
                           solved=sql.getSolved(session["login"]) if ("login" in session) else [])