Skip to content
Snippets Groups Projects
Commit e80912c0 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[databases][commands] Improve database map output

The scripts now lists by default only the users with
an active account. There's an option that will print
all users with their activate state.

The user email has been added to the output.
parent 3a342451
No related branches found
No related tags found
1 merge request!317Improve database map command output
Pipeline #36889 passed
...@@ -42,6 +42,13 @@ class Command(BaseCommand): ...@@ -42,6 +42,13 @@ class Command(BaseCommand):
default=None, default=None,
help="Path element up to which the the string must be cleaned", help="Path element up to which the the string must be cleaned",
) )
parser.add_argument(
"--show-all",
action="store_true",
dest="show_all",
default=False,
help="Show all users",
)
def handle(self, *ignored, **options): def handle(self, *ignored, **options):
...@@ -50,6 +57,7 @@ class Command(BaseCommand): ...@@ -50,6 +57,7 @@ class Command(BaseCommand):
for database in Database.objects.all(): for database in Database.objects.all():
folder = database.declaration["root_folder"] folder = database.declaration["root_folder"]
folder_filter = options["folder_filter"] folder_filter = options["folder_filter"]
show_all = options["show_all"]
if folder_filter: if folder_filter:
try: try:
start = folder.rindex(folder_filter) + len(folder_filter) start = folder.rindex(folder_filter) + len(folder_filter)
...@@ -61,10 +69,14 @@ class Command(BaseCommand): ...@@ -61,10 +69,14 @@ class Command(BaseCommand):
database.fullname(), database.get_sharing_display(), folder database.fullname(), database.get_sharing_display(), folder
) )
for user in [ for user in database.all_shared_with_users():
"{}: {} {}".format(user.username, user.first_name, user.last_name) if user.is_active or show_all:
for user in database.all_shared_with_users() user_info = "{}: {} {} {}".format(
]: user.username, user.first_name, user.last_name, user.email
self.stdout.write("{}, {}".format(db_info, user)) )
message = "{}, {}".format(db_info, user_info)
if show_all:
message += " active: {}".format(user.is_active)
self.stdout.write(message)
else: else:
self.stdout.write(db_info) self.stdout.write(db_info)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment