Skip to content

Commit

Permalink
DSRC Clean up (#1763)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbiggs authored Dec 23, 2024
1 parent ec1e98f commit 1960c60
Show file tree
Hide file tree
Showing 18 changed files with 246 additions and 166 deletions.
4 changes: 2 additions & 2 deletions .platform.app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ mounts:
source_path: logs

crons:
# Publish scheduled pages once an hour
# Publish scheduled pages once every half an hour
# https://docs.wagtail.org/en/stable/reference/management_commands.html#publish-scheduled
publish_scheduled:
spec: 0 * * * *
spec: */30 * * * *
cmd: poetry run python manage.py publish_scheduled

# Take snapshot at 5am every morning
Expand Down
10 changes: 8 additions & 2 deletions etna/api/tests/expected_results/article.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@
},
"display_content_warning": false,
"custom_warning_text": "",
"is_newly_published": false,
"tags": [
"Witchcraft"
],
"published_date": {
"value": "2000-01-01T00:00:00Z",
"year": 2000,
"month": 1,
"day": 1
},
"is_newly_published": false,
"body": [
{
"type": "content_section",
Expand Down Expand Up @@ -332,7 +338,7 @@
}
},
"last_published_at": "2000-01-02T00:00:00Z",
"is_newly_published": true
"is_newly_published": false
}
],
"latest_items": [],
Expand Down
2 changes: 1 addition & 1 deletion etna/api/tests/expected_results/article_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
}
},
"last_published_at": "2000-01-02T00:00:00Z",
"is_newly_published": true
"is_newly_published": false
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion etna/api/tests/expected_results/arts.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
}
},
"last_published_at": "2000-01-02T00:00:00Z",
"is_newly_published": true
"is_newly_published": false
},
{
"id": ARTICLE_ID,
Expand Down
2 changes: 1 addition & 1 deletion etna/api/tests/expected_results/author.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
}
},
"last_published_at": "2000-01-02T00:00:00Z",
"is_newly_published": true
"is_newly_published": false
}
],
"shop_items": []
Expand Down
2 changes: 1 addition & 1 deletion etna/api/tests/expected_results/early_modern.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
}
},
"last_published_at": "2000-01-02T00:00:00Z",
"is_newly_published": true
"is_newly_published": false
},
{
"id": ARTICLE_ID,
Expand Down
8 changes: 7 additions & 1 deletion etna/api/tests/expected_results/focused_article.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,17 @@
},
"display_content_warning": false,
"custom_warning_text": "",
"is_newly_published": true,
"tags": [
"Medicine",
"Witchcraft"
],
"is_newly_published": false,
"published_date": {
"value": "2000-01-02T00:00:00Z",
"year": 2000,
"month": 1,
"day": 2
},
"body": [],
"similar_items": [
{
Expand Down
2 changes: 1 addition & 1 deletion etna/api/tests/expected_results/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
}
},
"last_published_at": "2000-01-02T00:00:00Z",
"is_newly_published": true
"is_newly_published": false
}
]
}
4 changes: 2 additions & 2 deletions etna/api/tests/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ def setUpTestData(cls):
PageTimePeriod(time_period=cls.postwar),
],
first_published_at=DATE_1,
newly_published_at=DATE_1,
mark_new_on_next_publish=False,
published_date=DATE_1,
)

cls.focused_article = FocusedArticlePageFactory(
Expand All @@ -157,6 +156,7 @@ def setUpTestData(cls):
page_time_periods=[PageTimePeriod(time_period=cls.early_modern)],
author_tags=[AuthorTag(author=cls.author_page)],
first_published_at=DATE_2,
published_date=DATE_2,
)

cls.BODY_JSON = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Generated by Django 5.1.2 on 2024-12-19 16:48

import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("articles", "0112_alter_articlepage_body_alter_focusedarticlepage_body"),
]

def migrate_data(apps, schema_editor):
Article = apps.get_model("articles.ArticlePage")
FocusedArticle = apps.get_model("articles.FocusedArticlePage")
RecordArticle = apps.get_model("articles.RecordArticlePage")
for page in Article.objects.all():
if page.newly_published_at:
page.published_date = (
page.newly_published_at
or page.first_published_at
or django.utils.timezone.now()
)
page.save()
for page in FocusedArticle.objects.all():
if page.newly_published_at:
page.published_date = (
page.newly_published_at
or page.first_published_at
or django.utils.timezone.now()
)
page.save()
for page in RecordArticle.objects.all():
if page.newly_published_at:
page.published_date = (
page.newly_published_at
or page.first_published_at
or django.utils.timezone.now()
)
page.save()

operations = [
migrations.AddField(
model_name="articlepage",
name="published_date",
field=models.DateTimeField(
default=django.utils.timezone.now,
help_text="The date the page was published to the public.",
verbose_name="Published date",
),
),
migrations.AddField(
model_name="focusedarticlepage",
name="published_date",
field=models.DateTimeField(
default=django.utils.timezone.now,
help_text="The date the page was published to the public.",
verbose_name="Published date",
),
),
migrations.AddField(
model_name="recordarticlepage",
name="published_date",
field=models.DateTimeField(
default=django.utils.timezone.now,
help_text="The date the page was published to the public.",
verbose_name="Published date",
),
),
migrations.RunPython(migrate_data),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 5.1.2 on 2024-12-19 17:51
# etna:allowRemoveField

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("articles", "0113_remove_articlepage_mark_new_on_next_publish_and_more"),
]

operations = [
migrations.RemoveField(
model_name="articlepage",
name="mark_new_on_next_publish",
),
migrations.RemoveField(
model_name="articlepage",
name="newly_published_at",
),
migrations.RemoveField(
model_name="focusedarticlepage",
name="mark_new_on_next_publish",
),
migrations.RemoveField(
model_name="focusedarticlepage",
name="newly_published_at",
),
migrations.RemoveField(
model_name="recordarticlepage",
name="mark_new_on_next_publish",
),
migrations.RemoveField(
model_name="recordarticlepage",
name="newly_published_at",
),
]
Loading

0 comments on commit 1960c60

Please sign in to comment.