Skip to content

Commit

Permalink
Merge branch 'master' into change_button_description
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jul 17, 2017
2 parents 44858ee + bb6b2da commit 0bc17e6
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 33 deletions.
Expand Up @@ -341,7 +341,7 @@ function mapStateToProps(state) {
table_name: formData.datasource_name,
viz_type: formData.viz_type,
triggerRender: state.triggerRender,
datasourceType: state.datasource_type,
datasourceType: state.datasource.type,
datasourceId: state.datasource_id,
};
}
Expand Down
Expand Up @@ -187,7 +187,7 @@ function mapStateToProps(state) {
const form_data = getFormDataFromControls(state.controls);
return {
chartStatus: state.chartStatus,
datasource_type: state.datasource_type,
datasource_type: state.datasource.type,
controls: state.controls,
form_data,
standalone: state.standalone,
Expand Down
8 changes: 8 additions & 0 deletions superset/assets/javascripts/explore/stores/visTypes.js
Expand Up @@ -798,6 +798,14 @@ const visTypes = {
],
},
],
controlOverrides: {
all_columns_x: {
validators: [v.nonEmpty],
},
all_columns_y: {
validators: [v.nonEmpty],
},
},
},

horizon: {
Expand Down
3 changes: 2 additions & 1 deletion superset/assets/js_build.sh
Expand Up @@ -3,7 +3,8 @@ set -e
cd "$(dirname "$0")"
npm --version
node --version
npm install
npm install -g yarn
yarn
npm run sync-backend
npm run lint
npm run test
Expand Down
2 changes: 1 addition & 1 deletion superset/cli.py
Expand Up @@ -192,7 +192,7 @@ def worker(workers):
celery_app.conf.update(CELERYD_CONCURRENCY=workers)
elif config.get("SUPERSET_CELERY_WORKERS"):
celery_app.conf.update(
worker_concurrency=config.get("SUPERSET_CELERY_WORKERS"))
CELERYD_CONCURRENCY=config.get("SUPERSET_CELERY_WORKERS"))

worker = celery_worker.worker(app=celery_app)
worker.run()
Expand Down
1 change: 1 addition & 0 deletions superset/config.py
Expand Up @@ -46,6 +46,7 @@
SUPERSET_WEBSERVER_TIMEOUT = 60
EMAIL_NOTIFICATIONS = False
CUSTOM_SECURITY_MANAGER = None
SQLALCHEMY_TRACK_MODIFICATIONS = False
# ---------------------------------------------------------

# Your App secret key
Expand Down
49 changes: 21 additions & 28 deletions superset/security.py
Expand Up @@ -157,41 +157,39 @@ def create_custom_permissions():
merge_perm(sm, 'all_database_access', 'all_database_access')


def create_missing_datasource_perms(view_menu_set):
def create_missing_perms():
"""Creates missing perms for datasources, schemas and metrics"""

logging.info(
"Fetching a set of all perms to lookup which ones are missing")
all_pvs = set()
for pv in sm.get_session.query(sm.permissionview_model).all():
all_pvs.add((pv.permission.name, pv.view_menu.name))

def merge_pv(view_menu, perm):
"""Create permission view menu only if it doesn't exist"""
if view_menu and perm and (view_menu, perm) not in all_pvs:
merge_perm(sm, view_menu, perm)

logging.info("Creating missing datasource permissions.")
datasources = ConnectorRegistry.get_all_datasources(
db.session)
datasources = ConnectorRegistry.get_all_datasources(db.session)
for datasource in datasources:
if datasource and datasource.perm not in view_menu_set:
merge_perm(sm, 'datasource_access', datasource.get_perm())
if datasource.schema_perm:
merge_perm(sm, 'schema_access', datasource.schema_perm)

merge_pv('datasource_access', datasource.get_perm())
merge_pv('schema_access', datasource.schema_perm)

def create_missing_database_perms(view_menu_set):
logging.info("Creating missing database permissions.")
databases = db.session.query(models.Database).all()
for database in databases:
if database and database.perm not in view_menu_set:
merge_perm(sm, 'database_access', database.perm)
merge_pv('database_access', database.perm)


def create_missing_metrics_perm(view_menu_set):
"""Create permissions for restricted metrics
:param metrics: a list of metrics to be processed, if not specified,
all metrics are processed
:type metrics: models.SqlMetric or models.DruidMetric
"""
logging.info("Creating missing metrics permissions")
metrics = []
for datasource_class in ConnectorRegistry.sources.values():
metrics += list(db.session.query(datasource_class.metric_class).all())

for metric in metrics:
if (metric.is_restricted and metric.perm and
metric.perm not in view_menu_set):
merge_perm(sm, 'metric_access', metric.perm)
if (metric.is_restricted):
merge_pv('metric_access', metric.perm)


def sync_role_definitions():
Expand Down Expand Up @@ -220,12 +218,7 @@ def sync_role_definitions():
if conf.get('PUBLIC_ROLE_LIKE_GAMMA', False):
set_role('Public', pvms, is_gamma_pvm)

view_menu_set = []
for datasource_class in ConnectorRegistry.sources.values():
view_menu_set += list(db.session.query(datasource_class).all())
create_missing_datasource_perms(view_menu_set)
create_missing_database_perms(view_menu_set)
create_missing_metrics_perm(view_menu_set)
create_missing_perms()

# commit role and view menu updates
sm.get_session.commit()
2 changes: 1 addition & 1 deletion superset/views/core.py
Expand Up @@ -1374,7 +1374,7 @@ def testconn(self):
.get('connect_args', {}))
engine = create_engine(uri, connect_args=connect_args)
engine.connect()
return json.dumps(engine.table_names(), indent=4)
return json_success(json.dumps(engine.table_names(), indent=4))
except Exception as e:
logging.exception(e)
return json_error_response((
Expand Down
2 changes: 2 additions & 0 deletions tests/core_tests.py
Expand Up @@ -284,6 +284,7 @@ def test_testconn(self):
})
response = self.client.post('/superset/testconn', data=data, content_type='application/json')
assert response.status_code == 200
assert response.headers['Content-Type'] == 'application/json'

# validate that the endpoint works with the decrypted sqlalchemy uri
data = json.dumps({
Expand All @@ -292,6 +293,7 @@ def test_testconn(self):
})
response = self.client.post('/superset/testconn', data=data, content_type='application/json')
assert response.status_code == 200
assert response.headers['Content-Type'] == 'application/json'

def test_databaseview_edit(self, username='admin'):
# validate that sending a password-masked uri does not over-write the decrypted uri
Expand Down

0 comments on commit 0bc17e6

Please sign in to comment.