Skip to content

Commit

Permalink
Add: disabled status to Organization
Browse files Browse the repository at this point in the history
  • Loading branch information
arikfr committed Oct 15, 2017
1 parent 1380878 commit b5b5643
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions redash/models.py
Expand Up @@ -303,6 +303,16 @@ def google_apps_domains(self):
def is_public(self):
return self.settings.get(self.SETTING_IS_PUBLIC, False)

@property
def is_disabled(self):
return self.settings.get('is_disabled', False)

def disable(self):
self.settings['is_disabled'] = True

def enable(self):
self.settings['is_disabled'] = False

@property
def admin_group(self):
return self.groups.filter(Group.name == 'admin', Group.type == Group.BUILTIN_GROUP).first()
Expand Down
5 changes: 4 additions & 1 deletion redash/tasks/queries.py
Expand Up @@ -275,12 +275,13 @@ def refresh_queries():
for query in models.Query.outdated_queries():
if settings.FEATURE_DISABLE_REFRESH_QUERIES:
logging.info("Disabled refresh queries.")
elif query.org.is_disabled:
logging.info("Skipping refresh of %s because org is disabled.", query.id)
elif query.data_source is None:
logging.info("Skipping refresh of %s because the datasource is none.", query.id)
elif query.data_source.paused:
logging.info("Skipping refresh of %s because datasource - %s is paused (%s).", query.id, query.data_source.name, query.data_source.pause_reason)
else:
# if query.options and 'parameters' in query.options and len(query.options['parameters']) > 0:
if query.options and len(query.options.get('parameters', [])) > 0:
query_params = {p['name']: p['value']
for p in query.options['parameters']}
Expand Down Expand Up @@ -391,6 +392,8 @@ def refresh_schemas():
logger.info(u"task=refresh_schema state=skip ds_id=%s reason=paused(%s)", ds.id, ds.pause_reason)
elif ds.id in blacklist:
logger.info(u"task=refresh_schema state=skip ds_id=%s reason=blacklist", ds.id)
elif ds.org.is_disabled:
logger.info(u"task=refresh_schema state=skip ds_id=%s reason=org_disabled", ds.id)
else:
refresh_schema.apply_async(args=(ds.id,), queue="schemas")

Expand Down

0 comments on commit b5b5643

Please sign in to comment.