From 2cba0ade8460935be23cede9ec5aa31f2230bd1e Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 11 Nov 2017 09:52:11 -0600 Subject: [PATCH] Accept `None` as valid arg for `Grid.set_filter()` i.e. to effectively remove the filter --- tailbone/grids/core.py | 5 ++++- tailbone/views/batch/core.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index 7729a536..d2ea9b26 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -124,7 +124,10 @@ class Grid(object): self.sorters[key] = self.make_sorter(*args, **kwargs) def set_filter(self, key, *args, **kwargs): - self.filters[key] = self.make_filter(key, *args, **kwargs) + if len(args) == 1 and args[0] is None: + self.filters.pop(key, None) + else: + self.filters[key] = self.make_filter(key, *args, **kwargs) def set_label(self, key, label): self.labels[key] = label diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py index 90b675d0..c0eea65b 100644 --- a/tailbone/views/batch/core.py +++ b/tailbone/views/batch/core.py @@ -539,12 +539,12 @@ class BatchMasterView(MasterView): self.handler.refresh_batch_status(batch) except Exception as error: session.rollback() - log.warning("batch pre-fill failed: {}".format(batch), exc_info=True) + log.warning("batch population failed: %s", batch, exc_info=True) session.close() if progress: progress.session.load() progress.session['error'] = True - progress.session['error_msg'] = "Batch pre-fill failed: {} {}".format(error.__class__.__name__, error) + progress.session['error_msg'] = "Batch population failed: {} - {}".format(error.__class__.__name__, error) progress.session.save() return