From f17617c659f4b27bff3744f72f2c9dcbe17cdba9 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 19 Dec 2017 14:21:19 -0600 Subject: [PATCH] Accept `value_enum` kwarg when creating grid filter and do the "normal" thing for that if one is given --- tailbone/grids/filters.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tailbone/grids/filters.py b/tailbone/grids/filters.py index 87523d32..8b66b090 100644 --- a/tailbone/grids/filters.py +++ b/tailbone/grids/filters.py @@ -138,12 +138,17 @@ class GridFilter(object): value_renderer_factory = DefaultValueRenderer - def __init__(self, key, label=None, verbs=None, value_renderer=None, + def __init__(self, key, label=None, verbs=None, value_enum=None, value_renderer=None, default_active=False, default_verb=None, default_value=None, **kwargs): self.key = key self.label = label or prettify(key) self.verbs = verbs or self.get_default_verbs() - self.set_value_renderer(value_renderer or self.value_renderer_factory) + if value_renderer: + self.set_value_renderer(value_renderer) + elif value_enum: + self.set_value_renderer(EnumValueRenderer(value_enum)) + else: + self.set_value_renderer(self.value_renderer_factory) self.default_active = default_active self.default_verb = default_verb self.default_value = default_value