Skip to content

Commit

Permalink
[bugfix] missing redirect when datasource is missing (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 15, 2016
1 parent 4b48e9f commit e6e8ec9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion caravel/views.py
Expand Up @@ -449,6 +449,7 @@ class Caravel(BaseView):
@expose("/datasource/<datasource_type>/<datasource_id>/") # Legacy url
@log_this
def explore(self, datasource_type, datasource_id):
error_redirect = '/slicemodelview/list/'
datasource_class = models.SqlaTable \
if datasource_type == "table" else models.DruidDatasource
datasources = (
Expand All @@ -469,14 +470,15 @@ def explore(self, datasource_type, datasource_id):
)
if not datasource:
flash("The datasource seems to have been deleted", "alert")
return redirect(error_redirect)

all_datasource_access = self.appbuilder.sm.has_access(
'all_datasource_access', 'all_datasource_access')
datasource_access = self.appbuilder.sm.has_access(
'datasource_access', datasource.perm)
if not (all_datasource_access or datasource_access):
flash("You don't seem to have access to this datasource", "danger")
return redirect('/slicemodelview/list/')
return redirect(error_redirect)

action = request.args.get('action')
if action in ('save', 'overwrite'):
Expand Down

0 comments on commit e6e8ec9

Please sign in to comment.