Esempio n. 1
0
def change_is_keyholder(user_id):
    is_keyholder = request.form["keyholder"].lower() == "true"
    user = User.query.get(user_id)
    user.is_keyholder = is_keyholder
    db.session.commit()
    flash("changed keyholder status for %s" % user.nick, "success")
    return redirect_back(".users")
Esempio n. 2
0
File: main.py Progetto: ktt-ol/poisk
def change_keyholder(key_id):
    user = User.query.get(request.form['keyholder_id'])
    key = Key.query.get(key_id)
    change_key_holder(key, user)
    db.session.commit()

    notify_key_given(user, key, g.user)
    flash("changed keyholder for %s to %s" % (key.name, user), 'success')
    return redirect_back('admin_keys')
Esempio n. 3
0
def change_is_admin(user_id):
    is_admin = request.form["admin"].lower() == "true"
    if g.user.id == user_id:
        raise abort(400, "can't change own admin status")
    user = User.query.get(user_id)
    user.is_admin = is_admin
    db.session.commit()
    flash("changed admin status for %s" % user.nick, "success")
    return redirect_back(".users")
Esempio n. 4
0
def key_add():
    form = KeyNewForm()
    if form.validate_on_submit():
        key = Key(form.name.data)
        db.session.add(key)
        db.session.commit()
        flash("Key added", "success")
        return redirect_back("admin_keys")
    return render_template("admin/key_add.html", form=form)
Esempio n. 5
0
File: user.py Progetto: ktt-ol/poisk
def login_pin():
    form = PinLoginForm()
    if form.validate_on_submit():
        token = ActionToken.query.filter(ActionToken.hash == form.pin.data).first()
        login_user(token.user)
        db.session.delete(token)
        db.session.commit()
        flash("logged in")
        return redirect_back("index")
    return render_template("login_pin.html", next=oid.get_next_url(), form=form)
Esempio n. 6
0
File: main.py Progetto: ktt-ol/poisk
def key_take(key_id):
    key = Key.query.get(key_id)
    change_key_holder(key, g.user)
    db.session.commit()
    return redirect_back('keys')