Add grid totals support for NB donations

This commit is contained in:
Lance Edgar 2023-09-16 13:10:24 -05:00
parent 63138d03a8
commit c5a00be333

View file

@ -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)