diff --git a/superset/assets/src/components/StackTraceMessage.jsx b/superset/assets/src/components/StackTraceMessage.jsx
index ee190b7c5c..71b0972c25 100644
--- a/superset/assets/src/components/StackTraceMessage.jsx
+++ b/superset/assets/src/components/StackTraceMessage.jsx
@@ -25,6 +25,10 @@ class StackTraceMessage extends React.PureComponent {
return this.props.queryResponse && this.props.queryResponse.stacktrace;
}
+ hasLink() {
+ return this.props.queryResponse && this.props.queryResponse.link;
+ }
+
render() {
return (
@@ -33,6 +37,9 @@ class StackTraceMessage extends React.PureComponent {
onClick={() => this.setState({ showStackTrace: !this.state.showStackTrace })}
>
{this.props.message}
+ {this.hasLink() &&
+
(Request Access)
+ }
{this.hasTrace() &&
diff --git a/superset/views/base.py b/superset/views/base.py
index dc2e48f43a..d3fd1a4e06 100644
--- a/superset/views/base.py
+++ b/superset/views/base.py
@@ -41,11 +41,13 @@ def get_error_msg():
return error_msg
-def json_error_response(msg=None, status=500, stacktrace=None, payload=None):
+def json_error_response(msg=None, status=500, stacktrace=None, payload=None, link=None):
if not payload:
payload = {'error': str(msg)}
if stacktrace:
payload['stacktrace'] = stacktrace
+ if link:
+ payload['link'] = link
return Response(
json.dumps(payload, default=utils.json_iso_dttm_ser),
status=status, mimetype='application/json')
diff --git a/superset/views/core.py b/superset/views/core.py
index 14380c50ab..0ceefe79fc 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -68,14 +68,7 @@ DATASOURCE_MISSING_ERR = __('The datasource seems to have been deleted')
ACCESS_REQUEST_MISSING_ERR = __(
'The access requests seem to have been deleted')
USER_MISSING_ERR = __('The user seems to have been deleted')
-perms_instruction_link = config.get('PERMISSION_INSTRUCTIONS_LINK')
-if perms_instruction_link:
- DATASOURCE_ACCESS_ERR = __(
- "You don't have access to this datasource. (Gain access)"
- .format(perms_instruction_link),
- )
-else:
- DATASOURCE_ACCESS_ERR = __("You don't have access to this datasource")
+DATASOURCE_ACCESS_ERR = __("You don't have access to this datasource")
FORM_DATA_KEY_BLACKLIST = []
if not config.get('ENABLE_JAVASCRIPT_CONTROLS'):
@@ -1090,7 +1083,9 @@ class Superset(BaseSupersetView):
stacktrace=traceback.format_exc())
if not security_manager.datasource_access(viz_obj.datasource, g.user):
- return json_error_response(DATASOURCE_ACCESS_ERR, status=404)
+ return json_error_response(
+ DATASOURCE_ACCESS_ERR, status=404, link=config.get(
+ 'PERMISSION_INSTRUCTIONS_LINK'))
if csv:
return CsvResponse(
@@ -2708,7 +2703,9 @@ class Superset(BaseSupersetView):
"""
viz_obj = self.get_viz(slice_id)
if not security_manager.datasource_access(viz_obj.datasource):
- return json_error_response(DATASOURCE_ACCESS_ERR, status=401)
+ return json_error_response(
+ DATASOURCE_ACCESS_ERR, status=401, link=config.get(
+ 'PERMISSION_INSTRUCTIONS_LINK'))
return self.get_query_string_response(viz_obj)