Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type to listing view #1797

Merged
merged 7 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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.__class__.__name__

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