From fe4a178d43e6a112d6ca8a2fa20cf1930d79d28c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 26 Oct 2023 20:43:12 -0500 Subject: [PATCH] Add way to "ignore" a pending product and some related tweaks for sake of grid --- tailbone/grids/filters.py | 17 +++- tailbone/templates/products/pending/view.mako | 95 ++++++++++--------- tailbone/views/products.py | 87 +++++++++++++++-- 3 files changed, 143 insertions(+), 56 deletions(-) diff --git a/tailbone/grids/filters.py b/tailbone/grids/filters.py index 61d29554..41a3c1fa 100644 --- a/tailbone/grids/filters.py +++ b/tailbone/grids/filters.py @@ -612,10 +612,11 @@ class AlchemyNumericFilter(AlchemyGridFilter): """ value_renderer_factory = NumericValueRenderer - # expose greater-than / less-than verbs in addition to core - default_verbs = ['equal', 'not_equal', 'greater_than', 'greater_equal', - 'less_than', 'less_equal', 'between', - 'is_null', 'is_not_null', 'is_any'] + def default_verbs(self): + # expose greater-than / less-than verbs in addition to core + return ['equal', 'not_equal', 'greater_than', 'greater_equal', + 'less_than', 'less_equal', 'between', + 'is_null', 'is_not_null', 'is_any'] # TODO: what follows "works" in that it prevents an error...but from the # user's perspective it still fails silently...need to improve on front-end @@ -670,6 +671,14 @@ class AlchemyIntegerFilter(AlchemyNumericFilter): """ bigint = False + def default_verbs(self): + + # limited verbs if choices are defined + if self.choices: + return ['equal', 'not_equal', 'is_null', 'is_not_null', 'is_any'] + + return super().default_verbs() + def value_invalid(self, value): if value: if isinstance(value, int): diff --git a/tailbone/templates/products/pending/view.mako b/tailbone/templates/products/pending/view.mako index e3740c71..765c8838 100644 --- a/tailbone/templates/products/pending/view.mako +++ b/tailbone/templates/products/pending/view.mako @@ -7,25 +7,16 @@ ${product_lookup.tailbone_product_lookup_template()} -<%def name="object_helpers()"> - ${parent.object_helpers()} - % if instance.status_code == enum.PENDING_PRODUCT_STATUS_PENDING and master.has_perm('resolve_product'): - +<%def name="page_content()"> + ${parent.page_content()} + % if master.has_perm('ignore_product') and instance.status_code in (enum.PENDING_PRODUCT_STATUS_PENDING, enum.PENDING_PRODUCT_STATUS_READY): + ${h.form(master.get_action_url('ignore_product', instance), ref='ignoreProductForm')} + ${h.csrf_token(request)} + ${h.end_form()} + % endif + + % if master.has_perm('resolve_product') and instance.status_code in (enum.PENDING_PRODUCT_STATUS_PENDING, enum.PENDING_PRODUCT_STATUS_READY, enum.PENDING_PRODUCT_STATUS_IGNORED):