You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2018/08/21 17:10:47 UTC

[incubator-superset] branch master updated: [bug] 'an error has ooccured' when saving datasource (#5683)

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 50042af  [bug] 'an error has ooccured' when saving datasource (#5683)
50042af is described below

commit 50042af25d5d20a8dcc76ac419be4d2caff3b517
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Tue Aug 21 10:10:44 2018 -0700

    [bug] 'an error has ooccured' when saving datasource (#5683)
    
    The check_ownership was failing when Alpha user was saving a datasource
    from the datasource editor.
---
 superset/views/base.py       | 2 +-
 superset/views/datasource.py | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/superset/views/base.py b/superset/views/base.py
index 217415a..e15399a 100644
--- a/superset/views/base.py
+++ b/superset/views/base.py
@@ -307,7 +307,7 @@ def check_ownership(obj, raise_if_false=True):
     if hasattr(orig_obj, 'created_by'):
         owners += [orig_obj.created_by]
 
-    owner_names = [o.username for o in owners]
+    owner_names = [o.username for o in owners if o]
 
     if (
             g.user and hasattr(g.user, 'username') and
diff --git a/superset/views/datasource.py b/superset/views/datasource.py
index e00bfbb..360739c 100644
--- a/superset/views/datasource.py
+++ b/superset/views/datasource.py
@@ -9,6 +9,7 @@ import json
 
 from flask import request
 from flask_appbuilder import expose
+from flask_appbuilder.security.decorators import has_access_api
 from flask_babel import gettext as __
 
 from superset import appbuilder, db
@@ -19,6 +20,7 @@ from .base import BaseSupersetView, check_ownership, json_error_response
 class Datasource(BaseSupersetView):
     """Datasource-related views"""
     @expose('/save/', methods=['POST'])
+    @has_access_api
     def save(self):
         datasource = json.loads(request.form.get('data'))
         datasource_id = datasource.get('id')