superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [incubator-superset] branch master updated: allow selection of dbs where csv can be uploaded to (#5393)
Date Tue, 17 Jul 2018 22:38:19 GMT
This is an automated email from the ASF dual-hosted git repository.

timi 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 7f8eaee  allow selection of dbs where csv can be uploaded to (#5393)
7f8eaee is described below

commit 7f8eaee18da27cc348c2b60dbc81d5f06da604ac
Author: timifasubaa <30888507+timifasubaa@users.noreply.github.com>
AuthorDate: Tue Jul 17 15:38:16 2018 -0700

    allow selection of dbs where csv can be uploaded to (#5393)
---
 superset/forms.py                             |  8 +++++---
 superset/migrations/versions/1d9e835a84f9_.py | 29 +++++++++++++++++++++++++++
 superset/models/core.py                       |  3 ++-
 superset/views/core.py                        |  8 ++++----
 4 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/superset/forms.py b/superset/forms.py
index 0537ded..5983989 100644
--- a/superset/forms.py
+++ b/superset/forms.py
@@ -49,8 +49,10 @@ def filter_not_empty_values(value):
 
 class CsvToDatabaseForm(DynamicForm):
     # pylint: disable=E0211
-    def all_db_items():
-        return db.session.query(models.Database)
+    def csv_enabled_dbs():
+        return db.session.query(
+            models.Database).filter_by(
+                allow_csv_upload=True).all()
 
     name = StringField(
         _('Table Name'),
@@ -64,7 +66,7 @@ class CsvToDatabaseForm(DynamicForm):
             FileRequired(), FileAllowed(['csv'], _('CSV Files Only!'))])
     con = QuerySelectField(
         _('Database'),
-        query_factory=all_db_items,
+        query_factory=csv_enabled_dbs,
         get_pk=lambda a: a.id, get_label=lambda a: a.database_name)
     sep = StringField(
         _('Delimiter'),
diff --git a/superset/migrations/versions/1d9e835a84f9_.py b/superset/migrations/versions/1d9e835a84f9_.py
new file mode 100644
index 0000000..0a5a63f
--- /dev/null
+++ b/superset/migrations/versions/1d9e835a84f9_.py
@@ -0,0 +1,29 @@
+"""empty message
+
+Revision ID: 1d9e835a84f9
+Revises: 3dda56f1c4c6
+Create Date: 2018-07-16 18:04:07.764659
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '1d9e835a84f9'
+down_revision = '3dda56f1c4c6'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.sql import expression
+
+
+def upgrade():
+    op.add_column(
+    	'dbs',
+    	sa.Column(
+    		'allow_csv_upload',
+    		sa.Boolean(),
+    		nullable=False,
+    		server_default=expression.true()))
+
+def downgrade():
+    op.drop_column('dbs', 'allow_csv_upload')
+ 
\ No newline at end of file
diff --git a/superset/models/core.py b/superset/models/core.py
index 5cc3ee1..8c77814 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -619,6 +619,7 @@ class Database(Model, AuditMixinNullable, ImportMixin):
     expose_in_sqllab = Column(Boolean, default=False)
     allow_run_sync = Column(Boolean, default=True)
     allow_run_async = Column(Boolean, default=False)
+    allow_csv_upload = Column(Boolean, default=True)
     allow_ctas = Column(Boolean, default=False)
     allow_dml = Column(Boolean, default=False)
     force_ctas_schema = Column(String(250))
@@ -634,7 +635,7 @@ class Database(Model, AuditMixinNullable, ImportMixin):
     impersonate_user = Column(Boolean, default=False)
     export_fields = ('database_name', 'sqlalchemy_uri', 'cache_timeout',
                      'expose_in_sqllab', 'allow_run_sync', 'allow_run_async',
-                     'allow_ctas', 'extra')
+                     'allow_ctas', 'allow_csv_upload', 'extra')
     export_children = ['tables']
 
     def __repr__(self):
diff --git a/superset/views/core.py b/superset/views/core.py
index e64f1ff..9dc9030 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -193,14 +193,14 @@ class DatabaseView(SupersetModelView, DeleteMixin, YamlExportMixin):
 # noqa
 
     list_columns = [
         'database_name', 'backend', 'allow_run_sync', 'allow_run_async',
-        'allow_dml', 'creator', 'modified']
+        'allow_dml', 'allow_csv_upload', 'creator', 'modified']
     order_columns = [
         'database_name', 'allow_run_sync', 'allow_run_async', 'allow_dml',
-        'modified',
+        'modified', 'allow_csv_upload',
     ]
     add_columns = [
         'database_name', 'sqlalchemy_uri', 'cache_timeout', 'extra',
-        'expose_in_sqllab', 'allow_run_sync', 'allow_run_async',
+        'expose_in_sqllab', 'allow_run_sync', 'allow_run_async', 'allow_csv_upload',
         'allow_ctas', 'allow_dml', 'force_ctas_schema', 'impersonate_user',
         'allow_multi_schema_metadata_fetch',
     ]
@@ -326,7 +326,7 @@ class DatabaseAsync(DatabaseView):
         'id', 'database_name',
         'expose_in_sqllab', 'allow_ctas', 'force_ctas_schema',
         'allow_run_async', 'allow_run_sync', 'allow_dml',
-        'allow_multi_schema_metadata_fetch',
+        'allow_multi_schema_metadata_fetch', 'allow_csv_upload',
     ]
 
 


Mime
View raw message