Skip to content

Commit

Permalink
Merge pull request #773 from getredash/hotfix
Browse files Browse the repository at this point in the history
0.9.0 Hot Fixes
  • Loading branch information
arikfr committed Jan 19, 2016
2 parents 5b1abaa + a9ae3c9 commit 8473783
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/misc/backup_restore.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ How To: Backup your re:dash database and restore it on a different server
psql -c "grant select(id,name,type) ON data_sources to redash_reader;" redash
psql -c "grant select(id,name) ON users to redash_reader;" redash
psql -c "grant select on activity_log, events, queries, dashboards, widgets, visualizations, query_results to redash_reader;" redash
psql -c "grant select on events, queries, dashboards, widgets, visualizations, query_results to redash_reader;" redash
Create a new query in redash (using re:dash metadata as the data source) to test that everything is working as expected.
2 changes: 1 addition & 1 deletion migrations/0003_update_data_source_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ def update(data_source):


if __name__ == '__main__':
for data_source in DataSource.all():
for data_source in DataSource.select():
update(data_source)
2 changes: 1 addition & 1 deletion migrations/0011_migrate_bigquery_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def convert_p12_to_pem(p12file):

if __name__ == '__main__':

for ds in DataSource.all():
for ds in DataSource.select():

if ds.type == 'bigquery':
options = json.loads(ds.options)
Expand Down
2 changes: 1 addition & 1 deletion migrations/0014_migrate_existing_es_to_kibana.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

if __name__ == '__main__':

for ds in DataSource.all():
for ds in DataSource.select():
if ds.type == 'elasticsearch':
ds.type = 'kibana'
ds.save()
2 changes: 1 addition & 1 deletion rd_ui/app/views/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1><span class="glyphicon glyphicon-lock"></span></h1>
<div class="panel-body">
<div class="row">
<div class="col-lg-11">
Hi<p ng-bind-html="widget.text | markdown"></p>
<p ng-bind-html="widget.text | markdown"></p>
</div>
<div class="col-lg-1">
<span class="pull-right" ng-show="showControls">
Expand Down
9 changes: 6 additions & 3 deletions redash/handlers/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ def get(self):
else:
data_sources = models.DataSource.all(self.current_org, groups=self.current_user.groups)

response = []
response = {}
for ds in data_sources:
if ds.id in response:
continue

d = ds.to_dict()
d['view_only'] = all(project(ds.groups, self.current_user.groups).values())
response.append(d)
response[ds.id] = d

return response
return response.values()

@require_admin
def post(self):
Expand Down
4 changes: 2 additions & 2 deletions redash/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ def get_schema(self, refresh=False):

return schema

def add_group(self, group):
dsg = DataSourceGroup.create(group=group, data_source=self, view_only=False)
def add_group(self, group, view_only=False):
dsg = DataSourceGroup.create(group=group, data_source=self, view_only=view_only)
setattr(self, 'data_source_groups', dsg)

def remove_group(self, group):
Expand Down
2 changes: 1 addition & 1 deletion setup/amazon_linux/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ if [ $pg_user_exists -ne 0 ]; then
REDASH_READER_PASSWORD=$(mkpasswd)
sudo -u postgres psql -c "CREATE ROLE redash_reader WITH PASSWORD '$REDASH_READER_PASSWORD' NOCREATEROLE NOCREATEDB NOSUPERUSER LOGIN"
sudo -u redash psql -c "grant select(id,name,type) ON data_sources to redash_reader;" redash
sudo -u redash psql -c "grant select on activity_log, events, queries, dashboards, widgets, visualizations, query_results to redash_reader;" redash
sudo -u redash psql -c "grant select on events, queries, dashboards, widgets, visualizations, query_results to redash_reader;" redash

cd /opt/redash/current
sudo -u redash bin/run ./manage.py ds new -n "re:dash metadata" -t "pg" -o "{\"user\": \"redash_reader\", \"password\": \"$REDASH_READER_PASSWORD\", \"host\": \"localhost\", \"dbname\": \"redash\"}"
Expand Down
2 changes: 1 addition & 1 deletion setup/docker/create_database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ run_psql="docker-compose run --rm postgres psql -h $POSTGRES_PORT_5432_TCP_ADDR
$run_psql -c "CREATE ROLE redash_reader WITH PASSWORD 'redash_reader' NOCREATEROLE NOCREATEDB NOSUPERUSER LOGIN"
$run_psql -c "grant select(id,name,type) ON data_sources to redash_reader;"
$run_psql -c "grant select(id,name) ON users to redash_reader;"
$run_psql -c "grant select on activity_log, events, queries, dashboards, widgets, visualizations, query_results to redash_reader;"
$run_psql -c "grant select on events, queries, dashboards, widgets, visualizations, query_results to redash_reader;"

$run_redash /opt/redash/current/manage.py ds new -n "re:dash metadata" -t "pg" -o "{\"user\": \"redash_reader\", \"password\": \"redash_reader\", \"host\": \"postgres\", \"dbname\": \"postgres\"}"
2 changes: 1 addition & 1 deletion setup/ubuntu/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ if [ $pg_user_exists -ne 0 ]; then
sudo -u postgres psql -c "CREATE ROLE redash_reader WITH PASSWORD '$REDASH_READER_PASSWORD' NOCREATEROLE NOCREATEDB NOSUPERUSER LOGIN"
sudo -u redash psql -c "grant select(id,name,type) ON data_sources to redash_reader;" redash
sudo -u redash psql -c "grant select(id,name) ON users to redash_reader;" redash
sudo -u redash psql -c "grant select on activity_log, events, queries, dashboards, widgets, visualizations, query_results to redash_reader;" redash
sudo -u redash psql -c "grant select on events, queries, dashboards, widgets, visualizations, query_results to redash_reader;" redash

cd /opt/redash/current
sudo -u redash bin/run ./manage.py ds new -n "re:dash metadata" -t "pg" -o "{\"user\": \"redash_reader\", \"password\": \"$REDASH_READER_PASSWORD\", \"host\": \"localhost\", \"dbname\": \"redash\"}"
Expand Down
13 changes: 13 additions & 0 deletions tests/handlers/test_data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@ def test_fails_if_user_doesnt_belong_to_org(self):
other_admin = self.factory.create_admin(org=self.factory.create_org())
response = self.make_request("get", "/api/data_sources/{}/schema".format(self.factory.data_source.id), user=other_admin)
self.assertEqual(response.status_code, 404)


class TestDataSourceListGet(BaseTestCase):
def test_returns_each_data_source_once(self):
group = self.factory.create_group()
self.factory.user.groups.append(group.id)
self.factory.user.save()
self.factory.data_source.add_group(group)
self.factory.data_source.add_group(self.factory.org.default_group)
response = self.make_request("get", "/api/data_sources", user=self.factory.user)

self.assertEqual(len(response.json), 1)

0 comments on commit 8473783

Please sign in to comment.