Ejemplo n.º 1
0
def get_manage():
    db_users: Users = Users.by_all()

    users = list()

    for user in db_users:
        category_user: Category = Category.by_id(user.id_category)

        if category_user.category == 'manager':
            # Buscar gestor de evaluaciones
            manage_evaluation: ManageEvaluations = ManageEvaluations.by_id(
                user.id_manage_evaluation)

            # Buscar datos del team leader
            employees: Employees = Employees.by_id(user.id_employees)

            # Crear diccionario del usuario
            data_user = {
                '_id': user.id_users,
                'username': user.username,
                'name': employees.name,
                'last_name': employees.last_name,
                'date_last_evaluation': manage_evaluation.date_last_evaluation,
                'quantity_evaluations': manage_evaluation.quantity
            }
            users.append(data_user)

    return render_template('managers_admin.html', managers=users)
Ejemplo n.º 2
0
    def wrapper(*args, **kwargs):
        if 'user' in session:
            # Buscar categoria
            category: Category = Category.by_id(session['user']['category'])

            # Comprobar categoria
            name_category = category.category

            if name_category == 'admin':
                return function(*args, **kwargs)
            elif name_category == 'team_leader':
                return redirect(url_for('team_leader.home'))
            else:
                return redirect(url_for('auth.sign_in'))
        else:
            return redirect(url_for('auth.sign_in'))
Ejemplo n.º 3
0
def sign_in_action():
    # Instanciar la clase
    form = SignIn()

    # Obtener los datos ingresados
    username = form.username.data
    password = form.password.data

    # Buscar el usuario
    user: Users = Users.by_username(username)

    # Si existe el usuario
    if user != None:
        # Validar contraseña
        match = user.validate_password(password)

        # Buscar categoria
        category: Category = Category.by_id(user.id_category)

        # Si es valida
        if match:
            # Creo diccionario a guardar
            user = {'category': category.id_category, '_id': user.id_users}

            # Guardar usuario em la session
            session['user'] = user

            # Redireccionar usuario
            if category.category == 'team_leader':
                return redirect(url_for('team_leader.home'))
            elif category.category == 'admin':
                return redirect(url_for('admin.home'))
            elif category.category == 'manager':
                return redirect(url_for('manager.home'))
        else:
            flash("Upss! Password Incorrecta!")
            return redirect(url_for('auth.sign_in'))
    else:
        flash("Upss! Username Incorrecto!")
        return redirect(url_for("auth.sign_in"))
Ejemplo n.º 4
0
def get_admin():
    db_users: Users = Users.by_all()

    users = list()

    for user in db_users:
        category: Category = Category.by_id(user.id_category)

        if category.category == 'admin':
            # Buscar datos del team leader
            employees: Employees = Employees.by_id(user.id_employees)

            # Crear diccionario del usuario
            data_user = {
                '_id': user.username,
                'username': user.username,
                'name': employees.name,
                'last_name': employees.last_name
            }
            users.append(data_user)

    return render_template('admins_admin.html', admins=users)