forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: show connect data source link only to admins
- Loading branch information
Showing
3 changed files
with
15 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import json | ||
|
||
from flask import request | ||
from flask_login import login_required | ||
from flask_login import current_user, login_required | ||
from redash import models | ||
from redash.handlers import routes | ||
from redash.handlers.base import json_response, org_scoped_rule | ||
from redash.authentication import current_org | ||
from redash.permissions import require_admin | ||
|
||
|
||
@routes.route(org_scoped_rule('/api/organization/status'), methods=['GET']) | ||
@login_required | ||
def organization_status(org_slug=None): | ||
counters = { | ||
'users': models.User.query.count(), | ||
'alerts': models.Alert.query.count(), | ||
'data_sources': models.DataSource.query.count(), | ||
'queries': models.Query.query.filter(models.Query.is_archived==False).count(), | ||
'dashboards': models.Dashboard.query.filter(models.Dashboard.is_archived==False).count(), | ||
'users': models.User.all(current_org).count(), | ||
'alerts': models.Alert.all(group_ids=current_user.group_ids).count(), | ||
'data_sources': models.DataSource.all(current_org, group_ids=current_user.group_ids).count(), | ||
'queries': models.Query.all_queries(current_user.group_ids, current_user.id, drafts=True).count(), | ||
'dashboards': models.Dashboard.all(current_org, current_user.group_ids, current_user.id).count(), | ||
} | ||
return json_response(dict(object_counters=counters)) |