litestar-org / litestar-fullstack

Litestar Fullstack Reference Application with React, Vite, SQLAlchemy, Docker, Task Queues, and more!
https://fullstack.litestar.dev/
MIT License
340 stars 56 forks source link

Bug: `app users promote-to-superuser` command not working #141

Closed sorasful closed 8 months ago

sorasful commented 8 months ago

Description

It seems that app users promote-to-superuser command does not work because it tries to use __dict__ method which does not exist instead of using to_dict() method.

I'm going to create a pull request for this.

URL to code causing the issue

No response

MCVE

No response

Steps to reproduce

1. Clone the repository
2. run "make install"
3. run `app users promote-to-superuser --email "xx@xx.xx"`

Screenshots

No response

Logs

app users promote-to-superuser --email "xxx@xxx.xx"
Using Litestar app from env: 'app.asgi:app'
────────────────────────────────────────────────────────────────────────────────────────── Promote user to superuser. ───────────────────────────────────────────────────────────────────────────────────────────
Promoting user: %xxx@xxx.xx
Traceback (most recent call last):
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/bin/app", line 8, in <module>
    sys.exit(run_cli())
             ^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/src/app/__main__.py", line 23, in run_cli
    run_litestar_cli()
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/litestar/__main__.py", line 6, in run_cli
    litestar_group()
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/rich_click/rich_command.py", line 126, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/src/app/cli/commands.py", line 154, in promote_to_superuser
    anyio.run(_promote_to_superuser, email)
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/anyio/_core/_eventloop.py", line 73, in run
    return async_backend.run(func, args, {}, backend_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2001, in run
    return runner.run(wrapper())
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1989, in wrapper
    return await func(*args)
           ^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/src/app/cli/commands.py", line 146, in _promote_to_superuser
    data=user_in.__dict__,
         ^^^^^^^^^^^^^^^^
AttributeError: 'UserUpdate' object has no attribute '__dict__'. Did you mean: '__dir__'?
(.venv)  ✘ tevak@tuxedo  ~/dev/litestar-fullstack/backend   main LOCAL  app users promote-to-superu

Package Version

2.7.0

Platform