Skip to content

Commit

Permalink
CHORE: Latest develop changes -> etna-rosetta (#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbiggs authored Mar 1, 2024
2 parents d935c58 + 76e0453 commit 21c068e
Show file tree
Hide file tree
Showing 15 changed files with 760 additions and 687 deletions.
2 changes: 1 addition & 1 deletion .platform.app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ variables:
POETRY_VERSION: 1.6.1

# The size of the persistent disk of the application (in MB).
disk: 2048
disk: 4096

# The relationships of the application with services or other applications.
#
Expand Down
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

import os

from sysconfig import get_path
Expand Down Expand Up @@ -73,7 +74,6 @@
"wagtailfontawesomesvg",
"wagtailmedia",
"wagtail.contrib.settings",
"wagtail.contrib.styleguide",
"generic_chooser",
"wagtailmetadata",
"modelcluster",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 5.0.2 on 2024-02-22 14:20

from django.db import migrations


def set_newly_published_at(apps, schema_editor):
models = ["ArticlePage", "FocusedArticlePage", "RecordArticlePage"]

for model_name in models:
Model = apps.get_model("articles", model_name)
for page in Model.objects.all():
if not page.newly_published_at:
page.newly_published_at = page.first_published_at
page.save()


class Migration(migrations.Migration):

dependencies = [
("articles", "0100_remove_focusedarticlepage_author"),
("wagtailcore", "0091_remove_revision_submitted_for_moderation"),
]

operations = [
migrations.RunPython(set_newly_published_at),
]
24 changes: 13 additions & 11 deletions etna/articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.conf import settings
from django.db import models
from django.db.models.functions import Coalesce
from django.http import HttpRequest
from django.utils.functional import cached_property
from django.utils.safestring import mark_safe
Expand Down Expand Up @@ -136,7 +137,6 @@ class ArticleIndexPage(BasePageWithIntro):
[("featuredpages", FeaturedCollectionBlock())],
blank=True,
null=True,
use_json_field=True,
)

api_fields = BasePageWithIntro.api_fields + [
Expand All @@ -156,7 +156,14 @@ def get_context(self, request):
self.get_children()
.public()
.live()
.order_by("-first_published_at")
.order_by(
Coalesce(
"recordarticlepage__newly_published_at",
"focusedarticlepage__newly_published_at",
"articlepage__newly_published_at",
)
)
.reverse()
.specific()
)
return context
Expand Down Expand Up @@ -212,9 +219,7 @@ class ArticlePage(
The ArticlePage model.
"""

body = StreamField(
ArticlePageStreamBlock, blank=True, null=True, use_json_field=True
)
body = StreamField(ArticlePageStreamBlock, blank=True, null=True)

# DataLayerMixin overrides
gtm_content_group = "Explore the collection"
Expand Down Expand Up @@ -354,7 +359,7 @@ def latest_items(
)

return sorted(
latest_query_set, key=lambda x: x.first_published_at, reverse=True
latest_query_set, key=lambda x: x.newly_published_at, reverse=True
)[:3]


Expand All @@ -372,9 +377,7 @@ class FocusedArticlePage(
The FocusedArticlePage model.
"""

body = StreamField(
ArticlePageStreamBlock, blank=True, null=True, use_json_field=True
)
body = StreamField(ArticlePageStreamBlock, blank=True, null=True)

# DataLayerMixin overrides
gtm_content_group = "Explore the collection"
Expand Down Expand Up @@ -511,7 +514,7 @@ def latest_items(
)

return sorted(
latest_query_set, key=lambda x: x.first_published_at, reverse=True
latest_query_set, key=lambda x: x.newly_published_at, reverse=True
)[:3]


Expand Down Expand Up @@ -595,7 +598,6 @@ class RecordArticlePage(
max_num=1,
blank=True,
null=True,
use_json_field=True,
)

# DataLayerMixin overrides
Expand Down
13 changes: 5 additions & 8 deletions etna/collections/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ExplorerIndexPage(AlertMixin, BasePageWithIntro):
explorer.
"""

body = StreamField(ExplorerIndexPageStreamBlock, blank=True, use_json_field=True)
body = StreamField(ExplorerIndexPageStreamBlock, blank=True)

articles_title = models.CharField(
max_length=100,
Expand Down Expand Up @@ -115,7 +115,6 @@ class ExplorerIndexPage(AlertMixin, BasePageWithIntro):
[("featuredarticles", FeaturedArticlesBlock())],
blank=True,
null=True,
use_json_field=True,
)

content_panels = BasePageWithIntro.content_panels + [
Expand Down Expand Up @@ -169,7 +168,7 @@ class TopicExplorerIndexPage(RequiredHeroImageMixin, BasePageWithIntro):
This page lists all child TopicExplorerPages
"""

body = StreamField(TopicIndexPageStreamBlock, blank=True, use_json_field=True)
body = StreamField(TopicIndexPageStreamBlock, blank=True)

content_panels = (
BasePageWithIntro.content_panels
Expand Down Expand Up @@ -250,7 +249,7 @@ class Meta:
"articles.RecordArticlePage", blank=True, null=True, on_delete=models.SET_NULL
)

body = StreamField(TopicExplorerPageStreamBlock, blank=True, use_json_field=True)
body = StreamField(TopicExplorerPageStreamBlock, blank=True)

skos_id = models.CharField(
unique=True,
Expand Down Expand Up @@ -400,7 +399,7 @@ class TimePeriodExplorerIndexPage(RequiredHeroImageMixin, BasePageWithIntro):
This page lists all child TimePeriodExplorerPage
"""

body = StreamField(TopicIndexPageStreamBlock, blank=True, use_json_field=True)
body = StreamField(TopicIndexPageStreamBlock, blank=True)

content_panels = (
BasePageWithIntro.content_panels
Expand Down Expand Up @@ -479,9 +478,7 @@ class Meta:
featured_record_article = models.ForeignKey(
"articles.RecordArticlePage", blank=True, null=True, on_delete=models.SET_NULL
)
body = StreamField(
TimePeriodExplorerPageStreamBlock, blank=True, use_json_field=True
)
body = StreamField(TimePeriodExplorerPageStreamBlock, blank=True)
start_year = models.IntegerField(blank=False)
end_year = models.IntegerField(blank=False)
content_panels = (
Expand Down
1 change: 0 additions & 1 deletion etna/feedback/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class FeedbackPrompt(DraftStateMixin, RevisionMixin, ClusterableModel):
)
response_options = StreamField(
[("option", ResponseOptionBlock())],
use_json_field=True,
verbose_name=_("response options"),
)
thank_you_heading = models.CharField(
Expand Down
4 changes: 1 addition & 3 deletions etna/generic_pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@


class GeneralPage(BasePage):
body = StreamField(
GeneralPageStreamBlock, blank=True, null=True, use_json_field=True
)
body = StreamField(GeneralPageStreamBlock, blank=True, null=True)
content_panels = BasePage.content_panels + [
FieldPanel("body"),
]
2 changes: 1 addition & 1 deletion etna/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class HomePage(AlertMixin, BasePageWithIntro):
body = StreamField(HomePageStreamBlock, blank=True, null=True, use_json_field=True)
body = StreamField(HomePageStreamBlock, blank=True, null=True)

content_panels = BasePageWithIntro.content_panels + [
FieldPanel("body"),
Expand Down
12 changes: 6 additions & 6 deletions etna/records/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,9 @@ def test_back_to_search_render_with_catalogue_search_within_expiry(self):

session = self.client.session
session["back_to_search_url"] = search_url_gen_html_resp
session[
"back_to_search_url_timestamp"
] = self.back_to_search_url_timestamp.isoformat()
session["back_to_search_url_timestamp"] = (
self.back_to_search_url_timestamp.isoformat()
)
session.save()

response = self.client.get(self.record_detail_url)
Expand Down Expand Up @@ -854,9 +854,9 @@ def test_new_search_render_with_session(self):

session = self.client.session
session["back_to_search_url"] = browser_search_url
session[
"back_to_search_url_timestamp"
] = self.back_to_search_url_timestamp.isoformat()
session["back_to_search_url_timestamp"] = (
self.back_to_search_url_timestamp.isoformat()
)
session.save()

response = self.client.get(self.record_detail_url)
Expand Down
2 changes: 1 addition & 1 deletion etna/search/tests/test_search_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def setUp(self):
)

def test_render_sort_by_input_input_id(self):
expected_html = '<select name="sort_by" class="search-sort-view__form-select" id="id_sort_by_somevalue">'
expected_html = '<select name="sort_by" class="search-sort-view__form-select" id="id_sort_by_somevalue" aria-invalid="true">'
self.assertIn(
expected_html, render_sort_by_input(self.form, id_suffix="somevalue")
)
6 changes: 3 additions & 3 deletions etna/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ def set_session_info(self) -> None:
"""

self.request.session["back_to_search_url"] = self.request.get_full_path()
self.request.session[
"back_to_search_url_timestamp"
] = timezone.now().isoformat()
self.request.session["back_to_search_url_timestamp"] = (
timezone.now().isoformat()
)
return None


Expand Down
3 changes: 0 additions & 3 deletions etna/whatson/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,11 @@ class WhatsOnPage(BasePageWithIntro):
[("promoted_links", WhatsOnPromotedLinksBlock())],
blank=True,
max_num=1,
use_json_field=True,
)
large_card_links = StreamField(
[("large_card_links", LargeCardLinksBlock())],
blank=True,
max_num=1,
use_json_field=True,
)

def serve(self, request):
Expand Down Expand Up @@ -1072,7 +1070,6 @@ class ExhibitionPage(ArticleTagMixin, TopicalPageMixin, BasePageWithIntro):
[("relatedarticles", RelatedArticlesBlock())],
blank=True,
null=True,
use_json_field=True,
)

# Promote tab
Expand Down
6 changes: 3 additions & 3 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flake8==6.1.0
isort==5.12.0
black==23.11.0
flake8==7.0.0
isort==5.13.2
black==24.2.0
Loading

0 comments on commit 21c068e

Please sign in to comment.