From 98902599ff7db6eb186b2c415de13d28765ba087 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 23 Sep 2016 15:07:33 -0700 Subject: [PATCH] [hotfix] issues around empty params --- caravel/models.py | 4 ++++ caravel/viz.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/caravel/models.py b/caravel/models.py index a04a4e96da..5f7414ed61 100644 --- a/caravel/models.py +++ b/caravel/models.py @@ -271,6 +271,10 @@ class Slice(Model, AuditMixinNullable): slice_params['viz_type'] = self.viz_type if self.viz_type else "table" if url_params_multidict: slice_params.update(url_params_multidict) + to_del = [k for k in slice_params if k not in url_params_multidict] + for k in to_del: + del slice_params[k] + immutable_slice_params = ImmutableMultiDict(slice_params) return viz_types[immutable_slice_params.get('viz_type')]( self.datasource, diff --git a/caravel/viz.py b/caravel/viz.py index eb64ea68f8..b68b1ebdd2 100755 --- a/caravel/viz.py +++ b/caravel/viz.py @@ -1657,8 +1657,8 @@ class FilterBoxViz(BaseViz): def query_obj(self): qry = super(FilterBoxViz, self).query_obj() - groupby = self.form_data['groupby'] - if len(groupby) < 1: + groupby = self.form_data.get('groupby') + if len(groupby) < 1 and not self.form_data.get('date_filter'): raise Exception("Pick at least one filter field") qry['metrics'] = [ self.form_data['metric']] @@ -1666,7 +1666,7 @@ class FilterBoxViz(BaseViz): def get_data(self): qry = self.query_obj() - filters = [g for g in qry['groupby']] + filters = [g for g in self.form_data['groupby']] d = {} for flt in filters: qry['groupby'] = [flt]