Skip to content

Commit

Permalink
CRUD views improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 24, 2016
1 parent 0ca59bc commit e6920f8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
36 changes: 35 additions & 1 deletion panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def changed_by_fk(cls):
@property
def changed_on_(cls):
return utils.datetime_f(cls.changed_on)
@property
def created_by_(self):
return self.created_by or ''
@property
def changed_by_(self):
return self.changed_by or ''



class Url(Model, AuditMixinNullable):
Expand Down Expand Up @@ -80,6 +87,13 @@ def __repr__(self):
def datasource(self):
return self.table or self.druid_datasource

@property
def datasource_link(self):
if self.table:
return self.table.link
elif self.druid_datasource:
return self.druid_datasource.link

@property
@utils.memoized
def viz(self):
Expand Down Expand Up @@ -274,6 +288,14 @@ def __repr__(self):
def description_markeddown(self):
return utils.markdown(self.description)

@property
def url(self):
return '/tableview/edit/{}'.format(self.id)

@property
def link(self):
return '<a href="{self.url}">{self.table_name}</a>'.format(**locals())

@property
def perm(self):
return (
Expand Down Expand Up @@ -743,9 +765,21 @@ def perm(self):
"[{self.cluster_name}].[{self.datasource_name}]"
"(id:{self.id})").format(self=self)

@property
def url(self):
return '/datasourcemodelview/edit/{}'.format(self.id)

@property
def link(self):
return (
'<a href="{self.url}">'
'{self.datasource_name}</a>').format(**locals())

@property
def full_name(self):
return "[{self.cluster_name}].[{self.datasource_name}]".format(self=self)
return (
"[{self.cluster_name}]."
"[{self.datasource_name}]").format(self=self)

def __repr__(self):
return self.datasource_name
Expand Down
4 changes: 2 additions & 2 deletions panoramix/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class SliceModelView(PanoramixModelView, DeleteMixin):
can_add = False
list_columns = [
'slice_link', 'viz_type',
'datasource', 'created_by', 'changed_on_']
'datasource_link', 'created_by_', 'changed_on_']
edit_columns = [
'slice_name', 'description', 'viz_type', 'druid_datasource',
'table', 'dashboards', 'params']
Expand All @@ -223,7 +223,7 @@ class SliceModelView(PanoramixModelView, DeleteMixin):

class DashboardModelView(PanoramixModelView, DeleteMixin):
datamodel = SQLAInterface(models.Dashboard)
list_columns = ['dashboard_link', 'changed_by', 'changed_on_']
list_columns = ['dashboard_link', 'created_by_', 'changed_on_']
edit_columns = [
'dashboard_title', 'slug', 'slices', 'position_json', 'css',
'json_metadata']
Expand Down

0 comments on commit e6920f8

Please sign in to comment.