Esempio n. 1
0
def users_list() -> ResponseType:
    """
        Show a list of all users.

        :return: The response for this view.
    """

    # Get a search term and the resulting query. If no search term is given, all users will be returned.
    search_form = SearchForm()
    user_query = User.get_search_query(search_term=search_form.search_term)
    pagination = UserPagination(user_query.order_by(User.name))

    title = _('Users')
    return render_template('administration/users.html', title=title, pagination=pagination, search_form=search_form)
Esempio n. 2
0
def role_users(name: str) -> str:
    """
        List all users to whom the given role is assigned.

        :param name: The name of the role.
        :return: The HTML response.
    """
    role = Role.load_from_name(name)
    if role is None:
        abort(404)

    # Get a search term and the resulting query. If no search term is given, all users will be returned.
    search_form = SearchForm()
    user_query = User.get_search_query(query=role.users, search_term=search_form.search_term)

    # noinspection PyProtectedMember
    pagination = UserPagination(user_query.order_by(User.name, User._email))

    return render_template('administration/role_users.html', role=name, pagination=pagination, search_form=search_form)
Esempio n. 3
0
def role_users(name: str) -> str:
    """
        Show a list of all users to whom the given role is assigned.

        :param name: The name of the role.
        :return: The response for this view.
    """

    role = Role.load_from_name(name)
    if role is None:
        abort(404)

    # Get a search term and the resulting query. If no search term is given, all users will be returned.
    search_form = SearchForm()
    user_query = User.get_search_query(query=role.users, search_term=search_form.search_term)

    # noinspection PyProtectedMember
    pagination = UserPagination(user_query.order_by(User.name, User._email))

    return render_template('administration/role_users.html', role=name, pagination=pagination, search_form=search_form)