fix: use wutta hint from model if present, for rows title
This commit is contained in:
parent
fce7002675
commit
a83e53afad
2 changed files with 10 additions and 0 deletions
|
|
@ -3793,6 +3793,11 @@ class MasterView(View): # pylint: disable=too-many-public-methods
|
||||||
if hasattr(cls, "row_model_title"):
|
if hasattr(cls, "row_model_title"):
|
||||||
return cls.row_model_title
|
return cls.row_model_title
|
||||||
|
|
||||||
|
if model_class := cls.get_row_model_class():
|
||||||
|
if hasattr(model_class, "__wutta_hint__"):
|
||||||
|
if model_title := model_class.__wutta_hint__.get("model_title"):
|
||||||
|
return model_title
|
||||||
|
|
||||||
return cls.get_row_model_name()
|
return cls.get_row_model_name()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,11 @@ class TestMasterView(WebTestCase):
|
||||||
with patch.object(mod.MasterView, "row_model_class", new=MyModel):
|
with patch.object(mod.MasterView, "row_model_class", new=MyModel):
|
||||||
self.assertEqual(mod.MasterView.get_row_model_title(), "Dinosaur")
|
self.assertEqual(mod.MasterView.get_row_model_title(), "Dinosaur")
|
||||||
|
|
||||||
|
# model class may have wutta hint
|
||||||
|
MyModel.__wutta_hint__ = {"model_title": "T-Rex"}
|
||||||
|
with patch.object(mod.MasterView, "row_model_class", new=MyModel):
|
||||||
|
self.assertEqual(mod.MasterView.get_row_model_title(), "T-Rex")
|
||||||
|
|
||||||
def test_get_row_model_title_plural(self):
|
def test_get_row_model_title_plural(self):
|
||||||
|
|
||||||
# error by default (since no model class)
|
# error by default (since no model class)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue