Beispiel #1
0
def user_delete(user_id):
    user = User.query.get(user_id)

    if user.admin and User.admin_count() <= 1:
        redirect(url_for("user_index"))

    if not (current_user.admin or current_user.id == user.id):
        return redirect(url_for('user_index'))

    user.username = "******"
    user.password = "******"
    user.admin = False
    user.deleted = True

    db.session().commit()

    if user.id == current_user.id:
        logout_user()

    return redirect(url_for("user_index"))
Beispiel #2
0
def user_index():
    return render_template("user_index.html",
                           users=User.user_list(),
                           admin_count=User.admin_count())