2024-02-10 19:01:18 +01:00
|
|
|
import click
|
|
|
|
|
2024-02-11 15:10:29 +01:00
|
|
|
from db.vm6.databases import isp_database
|
|
|
|
from db.vm6.models import AuthUser
|
|
|
|
|
2024-02-10 19:01:18 +01:00
|
|
|
|
|
|
|
@click.group(help='access command for lazy example')
|
2024-02-11 15:10:29 +01:00
|
|
|
def cli():
|
|
|
|
pass
|
2024-02-10 19:01:18 +01:00
|
|
|
|
|
|
|
|
2024-02-11 15:10:29 +01:00
|
|
|
@cli.command(help='show all users and their roles on platform (DEMO EXAMPLE)')
|
|
|
|
def users():
|
|
|
|
# check and init connection to db:
|
|
|
|
isp_database.connect()
|
|
|
|
# get all fields from auth_user table
|
|
|
|
# SELECT * FROM auth_user;
|
|
|
|
all_users = AuthUser.select()
|
|
|
|
# Iterate fields and print to console users' email and role
|
|
|
|
for user in all_users:
|
|
|
|
result = f'{user.email} | {user.roles[0]}'
|
|
|
|
click.echo(result)
|
|
|
|
# Close connection
|
|
|
|
isp_database.close()
|