Commit 71bd1bb0 authored by François Ferry's avatar François Ferry

feat(museum): create Museum.title_with_city and use it in the view.

related: #2
parent 4db1f55d9454
Pipeline #26126 passed with stage
in 56 seconds
......@@ -16,3 +16,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-tuto entity's classes"""
from cubicweb.entities import AnyEntity, fetch_config
class Museum(AnyEntity):
__regid__ = "Museum"
fetch_attrs, cw_fetch_order = fetch_config(["name"])
@property
def title_with_city(self):
return f"{self.name} ({self.is_in[0].name})"
......@@ -27,5 +27,4 @@ class MuseumPrimaryView(PrimaryView):
"""Renders the entity title, by default using entity's
:meth:`dc_title()` method.
"""
city_name = entity.is_in[0].name
self.w(f"<h1>{entity.name} ({city_name})</h1>")
self.w(f"<h1>{entity.title_with_city}</h1>")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment