forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganization.py
More file actions
40 lines (31 loc) · 1.17 KB
/
organization.py
File metadata and controls
40 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import print_function
from click import argument
from flask.cli import AppGroup
from redash import models
manager = AppGroup(help="Organization management commands.")
@manager.command()
@argument('domains')
def set_google_apps_domains(domains):
"""
Sets the allowable domains to the comma separated list DOMAINS.
"""
organization = models.Organization.query.first()
k = models.Organization.SETTING_GOOGLE_APPS_DOMAINS
organization.settings[k] = domains.split(',')
models.db.session.add(organization)
models.db.session.commit()
print("Updated list of allowed domains to: {}".format(
organization.google_apps_domains))
@manager.command()
def show_google_apps_domains():
organization = models.Organization.query.first()
print("Current list of Google Apps domains: {}".format(
', '.join(organization.google_apps_domains)))
@manager.command()
def list():
"""List all organizations"""
orgs = models.Organization.query
for i, org in enumerate(orgs.order_by(models.Organization.name)):
if i > 0:
print("-" * 20)
print("Id: {}\nName: {}\nSlug: {}".format(org.id, org.name, org.slug))