fix: add basic "Show Totals" feature for main index grids
subclass must define what to display
This commit is contained in:
parent
184aa0630d
commit
bbcc17b064
4 changed files with 133 additions and 1 deletions
|
|
@ -34,6 +34,7 @@ class TestMasterView(WebTestCase):
|
|||
model_key="uuid",
|
||||
deletable_bulk=True,
|
||||
has_autocomplete=True,
|
||||
has_grid_totals=True,
|
||||
downloadable=True,
|
||||
executable=True,
|
||||
configurable=True,
|
||||
|
|
@ -694,6 +695,15 @@ class TestMasterView(WebTestCase):
|
|||
grid = view.make_model_grid(session=self.session)
|
||||
self.assertEqual(grid.tools, {})
|
||||
|
||||
# "show totals" tool added when applicable
|
||||
with patch.multiple(
|
||||
mod.MasterView, model_class=model.Setting, has_grid_totals=True
|
||||
):
|
||||
view = self.make_view()
|
||||
grid = view.make_model_grid(session=self.session)
|
||||
self.assertEqual(len(grid.tools), 1)
|
||||
self.assertIn("show-totals", grid.tools)
|
||||
|
||||
# delete-results tool added if master/perms allow
|
||||
with patch.multiple(
|
||||
mod.MasterView,
|
||||
|
|
@ -763,6 +773,16 @@ class TestMasterView(WebTestCase):
|
|||
self.assertEqual(len(data), 1)
|
||||
self.assertIs(data[0], setting)
|
||||
|
||||
def test_fetch_grid_totals(self):
|
||||
view = self.make_view()
|
||||
# with patch.object(view, "has_grid_totals", new=True):
|
||||
|
||||
# nb. default logic just returns generic stub info
|
||||
totals = view.fetch_grid_totals()
|
||||
self.assertIsInstance(totals, dict)
|
||||
self.assertIn("totals_html", totals)
|
||||
self.assertEqual(totals["totals_html"], "TODO: totals go here")
|
||||
|
||||
def test_configure_grid(self):
|
||||
model = self.app.model
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue