superset-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] timifasubaa closed pull request #5393: allow selection of dbs where csv can be uploaded to
Date Tue, 17 Jul 2018 22:38:18 GMT
timifasubaa closed pull request #5393: allow selection of dbs where csv can be uploaded to
URL: https://github.com/apache/incubator-superset/pull/5393
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/forms.py b/superset/forms.py
index 0537ded3e4..5983989787 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 @@ def all_db_items():
             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 0000000000..0a5a63fc81
--- /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 5cc3ee1b3f..8c77814a2c 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 e64f1ff4fb..9dc903083f 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',
     ]
 
 


 

----------------------------------------------------------------
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


Mime
View raw message