Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request getredash#1176 from someones/org_groups_list
Browse files Browse the repository at this point in the history
Add: 'list' command for org and groups CLI
  • Loading branch information
arikfr authored Jul 11, 2016
2 parents 2b8e953 + 3cf5147 commit 7d6db59
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions redash/cli/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,19 @@ def extract_permissions_string(permissions):
permissions = permissions.split(',')
permissions = [p.strip() for p in permissions]
return permissions


@manager.option('--org', dest='organization', default=None, help="The organization to limit to (leave blank for all).")
def list(organization=None):
"""List all groups"""
if organization:
org = models.Organization.get_by_slug(organization)
groups = models.Group.select().where(models.Group.org == org)
else:
groups = models.Group.select()

for i, group in enumerate(groups):
if i > 0:
print "-" * 20

print "Id: {}\nName: {}\nType: {}\nOrganization: {}".format(group.id, group.name, group.type, group.org.slug)
11 changes: 11 additions & 0 deletions redash/cli/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ def set_google_apps_domains(domains):
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)


@manager.command
def list():
"""List all organizations"""
orgs = models.Organization.select()
for i, org in enumerate(orgs):
if i > 0:
print "-" * 20

print "Id: {}\nName: {}\nSlug: {}".format(org.id, org.name, org.slug)

0 comments on commit 7d6db59

Please sign in to comment.