Skip to content

Commit

Permalink
[forms] Fix handling of NULLs
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bodley authored and Grace Guo committed Mar 25, 2019
1 parent 76d26f3 commit e83a07d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -291,10 +291,14 @@ def explore_json_url(self):
def edit_url(self):
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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -436,14 +440,18 @@ def url(self):
def datasources(self):
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
Expand Down
4 changes: 2 additions & 2 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,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')
Expand All @@ -599,7 +599,7 @@ class DashboardModelView(SupersetModelView, DeleteMixin): # noqa
'dashboard_link': _('Dashboard'),
'dashboard_title': _('Title'),
'slug': _('Slug'),
'slices': _('Charts'),
'charts': _('Charts'),
'owners': _('Owners'),
'creator': _('Creator'),
'modified': _('Modified'),
Expand Down

0 comments on commit e83a07d

Please sign in to comment.