Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
tuto
Commits
fe39b35b8bbe
Commit
71bd1bb0
authored
Dec 16, 2020
by
François Ferry
Browse files
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
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
cubicweb_tuto/entities.py
View file @
fe39b35b
...
...
@@ -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
}
)"
cubicweb_tuto/views.py
View file @
fe39b35b
...
...
@@ -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>"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment