feat: add MasterView registry/discovery mechanism
and show related MasterView link buttons when viewing App Table also show some more info about model class when viewing table
This commit is contained in:
parent
0619f070c7
commit
484e1f810a
8 changed files with 225 additions and 16 deletions
|
|
@ -9,6 +9,7 @@ from wuttjamaican.db.conf import check_alembic_current, make_alembic_config
|
|||
|
||||
from wuttaweb.testing import WebTestCase
|
||||
from wuttaweb.views import tables as mod
|
||||
from wuttaweb.views.users import UserView
|
||||
|
||||
|
||||
class TestAppTableView(WebTestCase):
|
||||
|
|
@ -75,6 +76,34 @@ version_locations = wuttjamaican.db:alembic/versions
|
|||
table = {"name": "poser_foo"}
|
||||
self.assertEqual(view.get_instance_title(table), "poser_foo")
|
||||
|
||||
def test_configure_form(self):
|
||||
view = self.make_view()
|
||||
table = {"name": "user", "description": "Represents a user"}
|
||||
|
||||
# no description widget by default
|
||||
form = view.make_form(model_instance=table, fields=["name", "description"])
|
||||
self.assertNotIn("description", form.widgets)
|
||||
|
||||
# but it gets added when configuring
|
||||
view.configure_form(form)
|
||||
self.assertIn("description", form.widgets)
|
||||
|
||||
def test_get_xref_buttons(self):
|
||||
self.pyramid_config.add_route("users", "/users/")
|
||||
model = self.app.model
|
||||
view = self.make_view()
|
||||
|
||||
# nb. must add this first
|
||||
self.pyramid_config.add_wutta_master_view(UserView)
|
||||
|
||||
# now xref button should work
|
||||
table = {"name": "person", "model_class": model.User}
|
||||
buttons = view.get_xref_buttons(table)
|
||||
self.assertEqual(len(buttons), 1)
|
||||
button = buttons[0]
|
||||
self.assertIn("Users", button)
|
||||
self.assertIn("http://example.com/users/", button)
|
||||
|
||||
def test_get_row_grid_data(self):
|
||||
model = self.app.model
|
||||
view = self.make_view()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue