Skip to content

Commit

Permalink
Only initiate permissions of valid metrics (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
x4base authored and mistercrunch committed Jun 16, 2016
1 parent 65d9feb commit db30f20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ def perm(self):
return (
"{parent_name}.[{obj.metric_name}](id:{obj.id})"
).format(obj=self,
parent_name=self.table.full_name)
parent_name=self.table.full_name) if self.table else None


class TableColumn(Model, AuditMixinNullable):
Expand Down Expand Up @@ -1372,7 +1372,9 @@ def perm(self):
return (
"{parent_name}.[{obj.metric_name}](id:{obj.id})"
).format(obj=self,
parent_name=self.datasource.full_name)
parent_name=self.datasource.full_name
) if self.datasource else None


class DruidColumn(Model, AuditMixinNullable):

Expand Down
2 changes: 1 addition & 1 deletion caravel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def init_metrics_perm(caravel, metrics=None):
for model in [models.SqlMetric, models.DruidMetric]:
metrics += list(db.session.query(model).all())

metric_perms = [metric.perm for metric in metrics]
metric_perms = filter(None, [metric.perm for metric in metrics])
for metric_perm in metric_perms:
merge_perm(sm, 'metric_access', metric_perm)

Expand Down

0 comments on commit db30f20

Please sign in to comment.