Exemplo n.º 1
0
def editUser():
    if session.get('token') is None:
        return render_template(
            '/login.html',
            message="You have to login to access this module",
            alertlevel="warning")
    user = User()

    id = request.form['id1']
    nome = request.form['name']
    email = request.form['email']
    senha = request.form['password']
    permissao = request.form['permission']

    users = user.search_all_users()

    try:
        response = user.edit_user(id, nome, email, senha, permissao)
        if response == False:
            return render_template('/users.html',
                                   message="Error while editing user",
                                   alertlevel="danger",
                                   users=users)
        else:
            return render_template('/users.html',
                                   message="User successfully edited",
                                   alertlevel="success",
                                   users=users)

    except Exception as e:
        return render_template(
            '/users.html',
            message=
            "A database error has occurred. Contact your system administrator",
            alertlevel="danger")
Exemplo n.º 2
0
def deleteUser():
    if session.get('token') is None:
        return render_template(
            '/login.html',
            message="You have to login to access this module",
            alertlevel="warning")
    userId = request.form['userId']
    user = User()
    try:
        response = user.delete_user(userId)
        users = user.search_all_users()
        if response == True:
            return render_template('/usersgrid.html',
                                   message="User deleted sucessfully",
                                   alertlevel="success",
                                   users=users)
        else:
            return render_template('/usersgrid.html',
                                   message="Error deleting user",
                                   alertlevel="warning",
                                   users=users)
    except Exception as e:
        return render_template(
            '/usersgrid.html',
            message=
            "A database error has occurred. Contact your system administrator",
            alertlevel="danger",
            users=users)
Exemplo n.º 3
0
def usersgrid():
    users = User()
    users = users.search_all_users()
    if session.get('token') is None:
        return render_template(
            '/login.html',
            message="You have to login to access this module",
            alertlevel="warning")
    return render_template('/usersgrid.html', users=users)
def findUser():
    id = request.form['id']
    user = User()
    users = user.search_all_users()
    try:
        response = user.search_user_by_id(id)
        if response == False:
            return "Erro ao buscar usuário"
        else:
            return render_template('/users.html', users=users, user1=response)

    except Exception as e:
        return 'Erro no servidor. Contate o analista responsável!'
Exemplo n.º 5
0
def findUser():
    if session.get('token') is None:
        return render_template(
            '/login.html',
            message="You have to login to access this module",
            alertlevel="warning")
    id = request.form['userId']
    user = User()
    users = user.search_all_users()
    try:
        response = user.search_user_by_id(id)
        if response == False:
            return render_template('/users.html',
                                   message="Error finding user",
                                   alertlevel="danger")
        else:
            return render_template('/users.html', users=users, user1=response)

    except Exception as e:
        return render_template(
            '/users.html',
            message=
            "A database error has occurred. Contact your system administrator",
            alertlevel="danger")
Exemplo n.º 6
0
def adduser():
    if session.get('token') is None:
        return render_template(
            '/login.html',
            message="You have to login to access this module",
            alertlevel="warning")
    user = User()
    nome = request.form['name']
    email = request.form['email']
    senha = request.form['password']
    permissao = request.form['permission']
    token = ''.join(
        random.choice(string.ascii_uppercase + string.digits)
        for _ in range(9))

    try:
        response = user.insert_new_user(nome, email, senha, token, permissao)
        users = user.search_all_users()
        if response == True:
            return render_template('/users.html',
                                   message="User added successfully",
                                   alertlevel="success",
                                   users=users)
        else:
            return render_template('/users.html',
                                   message="Error adding user",
                                   alertlevel="danger",
                                   users=users)

    except Exception as e:
        return render_template(
            '/users.html',
            message=
            "A database error has occurred. Contact your system administrator",
            alertlevel="danger",
            users=users)
def users():
    user = User()
    users = user.search_all_users()

    return render_template('/users.html', users=users)