superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnbod...@apache.org
Subject [incubator-superset] branch master updated: [forms] Fix handling of NULLs (#7078)
Date Mon, 25 Mar 2019 07:24:32 GMT
This is an automated email from the ASF dual-hosted git repository.

johnbodley 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 b3c4bd9  [forms] Fix handling of NULLs (#7078)
b3c4bd9 is described below

commit b3c4bd95efd5f74e822b7ed7a2db043ba7b8c6cf
Author: John Bodley <4567245+john-bodley@users.noreply.github.com>
AuthorDate: Mon Mar 25 00:24:26 2019 -0700

    [forms] Fix handling of NULLs (#7078)
---
 superset/models/core.py | 16 ++++++++++++----
 superset/views/core.py  |  4 ++--
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/superset/models/core.py b/superset/models/core.py
index c8435c2..b848604 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -163,7 +163,7 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
                      'viz_type', 'params', 'cache_timeout')
 
     def __repr__(self):
-        return self.slice_name
+        return self.slice_name or str(self.id)
 
     @property
     def cls_model(self):
@@ -292,9 +292,13 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
         return '/chart/edit/{}'.format(self.id)
 
     @property
+    def chart(self):
+        return self.slice_name or '<empty>'
+
+    @property
     def slice_link(self):
         url = self.slice_url
-        name = escape(self.slice_name)
+        name = escape(self.chart)
         return Markup(f'<a href="{url}">{name}</a>')
 
     def get_viz(self, force=False):
@@ -407,7 +411,7 @@ class Dashboard(Model, AuditMixinNullable, ImportMixin):
                      'description', 'css', 'slug')
 
     def __repr__(self):
-        return self.dashboard_title
+        return self.dashboard_title or str(self.id)
 
     @property
     def table_names(self):
@@ -437,13 +441,17 @@ class Dashboard(Model, AuditMixinNullable, ImportMixin):
         return {slc.datasource for slc in self.slices}
 
     @property
+    def charts(self):
+        return [slc.chart for slc in self.slices]
+
+    @property
     def sqla_metadata(self):
         # pylint: disable=no-member
         metadata = MetaData(bind=self.get_sqla_engine())
         return metadata.reflect()
 
     def dashboard_link(self):
-        title = escape(self.dashboard_title)
+        title = escape(self.dashboard_title or '<empty>')
         return Markup(f'<a href="{self.url}">{title}</a>')
 
     @property
diff --git a/superset/views/core.py b/superset/views/core.py
index cd73cb4..ad5153b 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -605,7 +605,7 @@ class DashboardModelView(SupersetModelView, DeleteMixin):  # noqa
     edit_columns = [
         'dashboard_title', 'slug', 'owners', 'position_json', 'css',
         'json_metadata']
-    show_columns = edit_columns + ['table_names', 'slices']
+    show_columns = edit_columns + ['table_names', 'charts']
     search_columns = ('dashboard_title', 'slug', 'owners')
     add_columns = edit_columns
     base_order = ('changed_on', 'desc')
@@ -632,7 +632,7 @@ class DashboardModelView(SupersetModelView, DeleteMixin):  # noqa
         'dashboard_link': _('Dashboard'),
         'dashboard_title': _('Title'),
         'slug': _('Slug'),
-        'slices': _('Charts'),
+        'charts': _('Charts'),
         'owners': _('Owners'),
         'creator': _('Creator'),
         'modified': _('Modified'),


Mime
View raw message