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

Commit

Permalink
Add 'manage.py groups list' command
Browse files Browse the repository at this point in the history
'groups list' simply prints out groups.
--org option is provided, limits printing to groups of
the specified organization.
--org accepts organization slugs.
  • Loading branch information
adamlwgriffiths committed Jul 11, 2016
1 parent 4d5d466 commit 3cf5147
Showing 1 changed file with 16 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)

0 comments on commit 3cf5147

Please sign in to comment.