You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/02/15 04:55:48 UTC

[GitHub] mistercrunch commented on a change in pull request #5186: Implement a React-based table editor

mistercrunch commented on a change in pull request #5186: Implement a React-based table editor
URL: https://github.com/apache/incubator-superset/pull/5186#discussion_r257104509
 
 

 ##########
 File path: superset/views/datasource.py
 ##########
 @@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+# pylint: disable=C,R,W
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
+import json
+
+from flask import request
+from flask_appbuilder import expose
+from flask_babel import gettext as __
+
+from superset import appbuilder, db
+from superset.connectors.connector_registry import ConnectorRegistry
+from .base import BaseSupersetView, check_ownership, json_error_response
+
+
+class Datasource(BaseSupersetView):
+    """Datasource-related views"""
+    @expose('/save/', methods=['POST'])
+    def save(self):
+        datasource = json.loads(request.form.get('data'))
+        datasource_id = datasource.get('id')
+        datasource_type = datasource.get('type')
+        orm_datasource = ConnectorRegistry.get_datasource(
+            datasource_type, datasource_id, db.session)
+
+        if not check_ownership(orm_datasource, raise_if_false=False):
+            return json_error_response(
+                __(
+                    'You are not authorized to modify '
+                    'this data source configuration'),
+                status='401',
 
 Review comment:
   Hmmm, how about creating a new permission `can_edit_any_datasource` ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org