Skip to content

Commit

Permalink
Add type to listing view (#1797)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbiggs authored Mar 4, 2025
1 parent d6789cd commit e6a55c4
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etna/api/tests/expected_results/article.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
"short_title": null,
"url": "/article_index/focused_article/",
"full_url": "http://localhost/article_index/focused_article/",
"type": "articles.FocusedArticlePage",
"type_label": "Focus on",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -350,6 +351,7 @@
"short_title": null,
"url": "/arts/",
"full_url": "http://localhost/arts/",
"type": "collections.TopicExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -378,6 +380,7 @@
"short_title": null,
"url": "/early_modern/",
"full_url": "http://localhost/early_modern/",
"type": "collections.TimePeriodExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand All @@ -404,6 +407,7 @@
"short_title": null,
"url": "/postwar/",
"full_url": "http://localhost/postwar/",
"type": "collections.TimePeriodExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down
3 changes: 3 additions & 0 deletions etna/api/tests/expected_results/article_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"short_title": null,
"url": "/article_index/article/",
"full_url": "http://localhost/article_index/article/",
"type": "articles.ArticlePage",
"type_label": "The story of",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -110,6 +111,7 @@
"short_title": null,
"url": "/article_index/article/",
"full_url": "http://localhost/article_index/article/",
"type": "articles.ArticlePage",
"type_label": "The story of",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -137,6 +139,7 @@
"short_title": null,
"url": "/article_index/focused_article/",
"full_url": "http://localhost/article_index/focused_article/",
"type": "articles.FocusedArticlePage",
"type_label": "Focus on",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down
3 changes: 3 additions & 0 deletions etna/api/tests/expected_results/arts.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"short_title": null,
"url": "/article_index/focused_article/",
"full_url": "http://localhost/article_index/focused_article/",
"type": "articles.FocusedArticlePage",
"type_label": "Focus on",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -150,6 +151,7 @@
"short_title": null,
"url": "/article_index/article/",
"full_url": "http://localhost/article_index/article/",
"type": "articles.ArticlePage",
"type_label": "The story of",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -179,6 +181,7 @@
"short_title": null,
"url": "/arts/highlight_gallery/",
"full_url": "http://localhost/arts/highlight_gallery/",
"type": "collections.HighlightGalleryPage",
"type_label": "In pictures",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down
3 changes: 3 additions & 0 deletions etna/api/tests/expected_results/early_modern.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"short_title": null,
"url": "/article_index/focused_article/",
"full_url": "http://localhost/article_index/focused_article/",
"type": "articles.FocusedArticlePage",
"type_label": "Focus on",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -149,6 +150,7 @@
"short_title": null,
"url": "/article_index/article/",
"full_url": "http://localhost/article_index/article/",
"type": "articles.ArticlePage",
"type_label": "The story of",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -178,6 +180,7 @@
"short_title": null,
"url": "/arts/highlight_gallery/",
"full_url": "http://localhost/arts/highlight_gallery/",
"type": "collections.HighlightGalleryPage",
"type_label": "In pictures",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down
4 changes: 4 additions & 0 deletions etna/api/tests/expected_results/focused_article.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"short_title": null,
"url": "/article_index/article/",
"full_url": "http://localhost/article_index/article/",
"type": "articles.ArticlePage",
"type_label": "The story of",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -163,6 +164,7 @@
"short_title": null,
"url": "/arts/",
"full_url": "http://localhost/arts/",
"type": "collections.TopicExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -191,6 +193,7 @@
"short_title": null,
"url": "/early_modern/",
"full_url": "http://localhost/early_modern/",
"type": "collections.TimePeriodExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -219,6 +222,7 @@
"short_title": null,
"url": "/people/author/",
"full_url": "http://localhost/people/author/",
"type": "people.PersonPage",
"type_label": null,
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down
3 changes: 3 additions & 0 deletions etna/api/tests/expected_results/highlight_gallery.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"short_title": null,
"url": "/article_index/article/",
"full_url": "http://localhost/article_index/article/",
"type": "articles.ArticlePage",
"type_label": "The story of",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -161,6 +162,7 @@
"short_title": null,
"url": "/arts/",
"full_url": "http://localhost/arts/",
"type": "collections.TopicExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -189,6 +191,7 @@
"short_title": null,
"url": "/early_modern/",
"full_url": "http://localhost/early_modern/",
"type": "collections.TimePeriodExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down
10 changes: 10 additions & 0 deletions etna/api/tests/expected_results/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"short_title": null,
"url": "/",
"full_url": "http://localhost/",
"type": "home.HomePage",
"type_label": null,
"teaser_text": "",
"teaser_image": null,
Expand All @@ -20,6 +21,7 @@
"short_title": null,
"url": "/arts/",
"full_url": "http://localhost/arts/",
"type": "collections.TopicExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand All @@ -46,6 +48,7 @@
"short_title": null,
"url": "/arts/highlight_gallery/",
"full_url": "http://localhost/arts/highlight_gallery/",
"type": "collections.HighlightGalleryPage",
"type_label": "In pictures",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -73,6 +76,7 @@
"short_title": null,
"url": "/early_modern/",
"full_url": "http://localhost/early_modern/",
"type": "collections.TimePeriodExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand All @@ -99,6 +103,7 @@
"short_title": null,
"url": "/postwar/",
"full_url": "http://localhost/postwar/",
"type": "collections.TimePeriodExplorerPage",
"type_label": "Explore the collection",
"teaser_text": "Teaser text",
"teaser_image": {
Expand All @@ -125,6 +130,7 @@
"short_title": null,
"url": "/people/",
"full_url": "http://localhost/people/",
"type": "people.PeopleIndexPage",
"type_label": null,
"teaser_text": "Teaser text",
"teaser_image": {
Expand All @@ -151,6 +157,7 @@
"short_title": null,
"url": "/people/author/",
"full_url": "http://localhost/people/author/",
"type": "people.PersonPage",
"type_label": null,
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -219,6 +226,7 @@
"short_title": null,
"url": "/article_index/",
"full_url": "http://localhost/article_index/",
"type": "articles.ArticleIndexPage",
"type_label": null,
"teaser_text": "Teaser text",
"teaser_image": {
Expand All @@ -245,6 +253,7 @@
"short_title": null,
"url": "/article_index/article/",
"full_url": "http://localhost/article_index/article/",
"type": "articles.ArticlePage",
"type_label": "The story of",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down Expand Up @@ -272,6 +281,7 @@
"short_title": null,
"url": "/article_index/focused_article/",
"full_url": "http://localhost/article_index/focused_article/",
"type": "articles.FocusedArticlePage",
"type_label": "Focus on",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down
1 change: 1 addition & 0 deletions etna/api/tests/expected_results/people.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"short_title": null,
"url": "/people/author/",
"full_url": "http://localhost/people/author/",
"type": "people.PersonPage",
"type_label": null,
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down
1 change: 1 addition & 0 deletions etna/api/tests/expected_results/postwar.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"short_title": null,
"url": "/article_index/article/",
"full_url": "http://localhost/article_index/article/",
"type": "articles.ArticlePage",
"type_label": "The story of",
"teaser_text": "Teaser text",
"teaser_image": {
Expand Down
5 changes: 5 additions & 0 deletions etna/core/models/basepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,17 @@ def mourning_notice(self):

return MourningNotice.objects.first()

@cached_property
def type(self):
return self._meta.label

default_api_fields = [
APIField("id"),
APIField("title"),
APIField("short_title"),
APIField("url"),
APIField("full_url"),
APIField("type"),
APIField("type_label"),
APIField("teaser_text"),
APIField(
Expand Down

0 comments on commit e6a55c4

Please sign in to comment.