diff --git a/beat/web/databases/management/commands/print_db_access_map.py b/beat/web/databases/management/commands/print_db_access_map.py index 3445689de056b5190dfbac61dc707ae15f324bd2..2f7b2e168aaa58d94a2a164a23b984d707ec56c2 100644 --- a/beat/web/databases/management/commands/print_db_access_map.py +++ b/beat/web/databases/management/commands/print_db_access_map.py @@ -42,6 +42,13 @@ class Command(BaseCommand): default=None, 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): @@ -50,6 +57,7 @@ class Command(BaseCommand): for database in Database.objects.all(): folder = database.declaration["root_folder"] folder_filter = options["folder_filter"] + show_all = options["show_all"] if folder_filter: try: start = folder.rindex(folder_filter) + len(folder_filter) @@ -61,10 +69,14 @@ class Command(BaseCommand): database.fullname(), database.get_sharing_display(), folder ) - for user in [ - "{}: {} {}".format(user.username, user.first_name, user.last_name) - for user in database.all_shared_with_users() - ]: - self.stdout.write("{}, {}".format(db_info, user)) + for user in database.all_shared_with_users(): + if user.is_active or show_all: + user_info = "{}: {} {} {}".format( + user.username, user.first_name, user.last_name, user.email + ) + message = "{}, {}".format(db_info, user_info) + if show_all: + message += " active: {}".format(user.is_active) + self.stdout.write(message) else: self.stdout.write(db_info)