Ejemplo n.º 1
0
def does_user_email_exist(email: str) -> bool:
    """Returns whether a user email exists in the database.
    Args:
        email: An email that may belong to a user.
    Returns:
        Returns true if the email exists, false otherwise.
    """
    return get_instance_by_field(User, User.email, email) is not None
Ejemplo n.º 2
0
def get_user_by_username(username: str) -> User:
    """Returns an user with the username email.

    Args:
        username: An user's email.

    Returns:
        Returns an user if an user has the usermail, otherwise returns None.
    """
    return get_instance_by_field(User, User.username, username)
Ejemplo n.º 3
0
def get_user_by_id(id: int) -> User:
    """Returns an user with the given email.

    Args:
        email: An user's email.

    Returns:
        Returns an user if an user has the email, otherwise returns None.
    """
    return get_instance_by_field(User, User.id, id)
Ejemplo n.º 4
0
def get_user_by_email(email: str) -> User:
    """Returns an user with the given email.

    Args:
        email: An user's email.

    Returns:
        Returns an user if an user has the email, otherwise returns None.
    """
    return get_instance_by_field(User, User.email, email)
Ejemplo n.º 5
0
def get_employee_by_id(employee_id: int) -> Employee:
    """Returns an employee with the given email.

    Args:
        employee_id: An employee's id.

    Returns:
        Returns an employee if an employee has the email, otherwise returns None.
    """
    return get_instance_by_field(Employee, Employee.id, employee_id)
Ejemplo n.º 6
0
def get_employee_by_email(email: str) -> Employee:
    """Returns an employee with the given email.

    Args:
        email: An employee's email.

    Returns:
        Returns an employee if an employee has the email, otherwise returns None.
    """
    return get_instance_by_field(Employee, Employee.email, email)
Ejemplo n.º 7
0
def does_role_name_exist(name: str) -> bool:
    """Returns whether a rolel exists in the database.

    Args:
        name: A name that may belong to a role.

    Returns:
        Returns true if the name exists, false otherwise.
    """
    return get_instance_by_field(Role, Role.name, name) is not None
Ejemplo n.º 8
0
def get_group_by_id(group_id: int) -> Group:
    """Returns a group with the given id.

    Args:
        group_id: The id of a group.

    Returns:
        Returns a group with the given role_id,
        otherwise returns None.
    """
    return get_instance_by_field(Group, Group.id, group_id)
Ejemplo n.º 9
0
def get_role_by_id(role_id: int) -> Role:
    """Returns a role with the given id.

    Args:
        role_id: The id of a role.

    Returns:
        Returns a role with the given role_id,
        otherwise returns None.
    """
    return get_instance_by_field(Role, Role.id, role_id)
Ejemplo n.º 10
0
def get_app_by_id(app_id: int):
    """Returns an app with the matching id.

    Args:
        app_id: The id to search an app by.

    Returns:
        Returns an App object with the given id if it exists, otherwise
        returns None.
    """
    return get_instance_by_field(App, App.id, app_id)