From c5a00be3330cc0ff71cd32b1458315b5c037fe88 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 16 Sep 2023 13:10:24 -0500 Subject: [PATCH] Add grid totals support for NB donations --- tailbone_nationbuilder/views/nationbuilder/donations.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tailbone_nationbuilder/views/nationbuilder/donations.py b/tailbone_nationbuilder/views/nationbuilder/donations.py index c5bed33..3187b85 100644 --- a/tailbone_nationbuilder/views/nationbuilder/donations.py +++ b/tailbone_nationbuilder/views/nationbuilder/donations.py @@ -36,6 +36,7 @@ class NationBuilderCacheDonationView(NationBuilderMasterView): model_class = NationBuilderCacheDonation url_prefix = '/nationbuilder/cache/donations' route_prefix = 'nationbuilder.cache.donations' + supports_grid_totals = True has_versions = True labels = { @@ -95,6 +96,12 @@ class NationBuilderCacheDonationView(NationBuilderMasterView): g.set_sort_defaults('created_at', 'desc') + def fetch_grid_totals(self): + app = self.get_rattail_app() + results = self.get_effective_data() + total = sum([donation.amount for donation in results]) + return {'totals_display': app.render_currency(total)} + def configure_form(self, f): super().configure_form(f)