Ejemplo n.º 1
0
def update_user():
    if request.method == 'POST':
        password = request.form['password']
        password_hash = ""
        if password == "":
            password_hash = ""
        else:
            password_hash = generate_password_hash(request.form['password'])

        DbUtils.update_user(request.form['id'], request.form['login'],
                            password_hash, request.form['email'],
                            request.form['user_type'],
                            request.form['full_name'])
        users = DbUtils.select_users()
        return render_template('manage_users.html',
                               users=users,
                               len=len(users),
                               login=app.config['USER'].login,
                               type=app.config['USER'].type)
    users = DbUtils.select_users()
    return render_template('manage_users.html',
                           users=users,
                           len=len(users),
                           login=app.config['USER'].login,
                           type=app.config['USER'].type)
Ejemplo n.º 2
0
def edit_user():
    if request.method == 'POST':
        action_type = request.form['submit']
        if action_type == "Удалить":
            DbUtils.delete_user(request.form['id'])

            users = DbUtils.select_users()
            return render_template("manage_users.html",
                                   users=users,
                                   len=len(users),
                                   login=app.config['USER'].login,
                                   type=app.config['USER'].type)
        elif action_type == "Изменить":
            return render_template('edit_user.html',
                                   id=request.form['id'],
                                   login2=request.form['login'],
                                   email=request.form['email'],
                                   full_name=request.form['full_name'],
                                   user_type=request.form['user_type'],
                                   login=app.config['USER'].login,
                                   type=app.config['USER'].type)

    return render_template('edit_user.html',
                           login=app.config['USER'].login,
                           type=app.config['USER'].type)
Ejemplo n.º 3
0
def manage_users():
    users = DbUtils.select_users()
    return render_template('manage_users.html',
                           users=users,
                           len=len(users),
                           login=app.config['USER'].login,
                           type=app.config['USER'].type)
Ejemplo n.º 4
0
def add_user():
    if request.method == 'POST':
        DbUtils.insert_user(request.form['login'], request.form['password'],
                            request.form['email'], request.form['user_type'],
                            request.form['full_name'])
        users = DbUtils.select_users()
        return render_template('manage_users.html',
                               users=users,
                               len=len(users),
                               login=app.config['USER'].login,
                               type=app.config['USER'].type)
    return render_template('add_user.html',
                           login=app.config['USER'].login,
                           type=app.config['USER'].type)