list_realms: Print the full domains of the organizations.

This adds a column to display the full domains of realms.  Tweaked by
tabbott to use fewer columns.

Fixes part of #11015.
This commit is contained in:
Hudda 2018-12-28 12:48:34 +05:30 committed by Tim Abbott
parent 93e3543e5e
commit 50e14dbe97
1 changed files with 9 additions and 5 deletions

View File

@ -24,20 +24,24 @@ Usage examples:
def handle(self, *args: Any, **options: Any) -> None: def handle(self, *args: Any, **options: Any) -> None:
realms = Realm.objects.all() realms = Realm.objects.all()
outer_format = "%-5s %-40s %-40s" outer_format = "%-5s %-20s %-30s %-50s"
inner_format = "%-40s %s" inner_format = "%-40s %s"
deactivated = False deactivated = False
if not options["all"]: if not options["all"]:
print(outer_format % ("id", "string_id", "name")) print(outer_format % ("id", "string_id", "name", "domain"))
print(outer_format % ("--", "---------", "----")) print(outer_format % ("--", "---------", "----", "------"))
for realm in realms: for realm in realms:
if realm.deactivated: if realm.deactivated:
print(self.style.ERROR(outer_format % (realm.id, realm.string_id, realm.name))) print(self.style.ERROR(outer_format % (
realm.id,
realm.string_id,
realm.name,
realm.uri)))
deactivated = True deactivated = True
else: else:
print(outer_format % (realm.id, realm.string_id, realm.name)) print(outer_format % (realm.id, realm.string_id, realm.name, realm.uri))
if deactivated: if deactivated:
print(self.style.WARNING("\nRed rows represent deactivated realms.")) print(self.style.WARNING("\nRed rows represent deactivated realms."))
sys.exit(0) sys.exit(0)