Code Monkey home page Code Monkey logo

Comments (6)

dosubot avatar dosubot commented on July 24, 2024 2

The superset fab list-users command does not include the firstname, lastname, and active columns in its output because these columns are not specified in the list_columns attribute of the UserModelView class. The list_columns attribute determines which columns are displayed when listing users.

To include the firstname, lastname, and active columns in the output, you need to modify the UserModelView class to specify these columns in the list_columns attribute. Here is an example of how you can do this:

from flask_appbuilder import ModelView
from flask_appbuilder.security.sqla.models import User

class CustomUserModelView(ModelView):
    datamodel = SQLAInterface(User)
    list_columns = ["id", "username", "firstname", "lastname", "active", "email"]

appbuilder.add_view(
    CustomUserModelView,
    "List Users",
    icon="fa-user",
    label=_("List Users"),
    category="Security",
    category_icon="fa-cogs",
)

By adding the firstname, lastname, and active columns to the list_columns attribute, they will be included in the output of the superset fab list-users command [1].

Details

About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

from superset.

dosubot avatar dosubot commented on July 24, 2024 2

The superset fab list-users command is implemented in the superset/cli/fab.py file. The entry point for the CLI is the superset function in the superset/cli/main.py file, which dynamically adds sub-commands from the superset.cli package, including the list-users command.

Here is a snippet showing how sub-commands are added:

# superset/cli/main.py
@click.group(
    cls=FlaskGroup,
    context_settings={"token_normalize_func": normalize_token},
)
@with_appcontext
def superset() -> None:
    """\033[1;37mThe Apache Superset CLI\033[0m"""
    @app.shell_context_processor
    def make_shell_context() -> dict[str, Any]:
        return {"app": app, "db": db}

# add sub-commands
for load, module_name, is_pkg in pkgutil.walk_packages(
    cli.__path__, cli.__name__ + "."
):
    module = importlib.import_module(module_name)
    for attribute in module.__dict__.values():
        if isinstance(attribute, (click.core.Command, click.core.Group)):
            superset.add_command(attribute)

            if isinstance(attribute, click.core.Group):
                break

This setup allows the superset CLI to include various sub-commands defined in the superset.cli package [1].

Details

About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

from superset.

dosubot avatar dosubot commented on July 24, 2024 2

It appears there might be some confusion or outdated information regarding the file structure. The list-users command and its related functionalities might be located in a different file or have been refactored.

To locate the exact implementation of the list-users command, you can search for the command definition within the superset/cli directory. Look for files that define CLI commands using the click library, as this is commonly used for command-line interfaces in Python.

If you need to modify the output of the list-users command to include firstname, lastname, and active columns, you can refer to the UserResponseSchema class in the superset/views/users/schemas.py file, which already includes these fields:

class UserResponseSchema(Schema):
    id = Integer()
    username = String()
    email = String()
    first_name = String()
    last_name = String()
    is_active = Boolean()
    is_anonymous = Boolean()

Additionally, the bootstrap_user_data function in the superset/views/utils.py file can be used to fetch these details:

def bootstrap_user_data(user: User, include_perms: bool = False) -> dict[str, Any]:
    payload = {
        "username": user.username,
        "firstName": user.first_name,
        "lastName": user.last_name,
        "isActive": user.is_active,
        "isAnonymous": user.is_anonymous,
    }
    return payload

These utilities can help you extend the list-users command to include the desired columns [1][2].

Details

About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

from superset.

xavier-GitHub76 avatar xavier-GitHub76 commented on July 24, 2024

@dosu where the superset fab list-users command is defined ?

from superset.

xavier-GitHub76 avatar xavier-GitHub76 commented on July 24, 2024

@dosu I find superset/cli/main.py file but not superset/cli/fab.py file

from superset.

rusackas avatar rusackas commented on July 24, 2024

@dpgaspar might know if this is a bug or intentional by design for some reason.

from superset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.