Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
38 changes: 38 additions & 0 deletions blog/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,44 @@ def test_user_cannot_see_unpublished_entries(self):
response = self.client.get(published_url)
self.assertEqual(response.status_code, 200)

def test_archive_view_titles(self):
headline = "Pride and Prejudice - Review"
pub_date = date(2005, 7, 21)
Entry.objects.create(
pub_date=pub_date,
is_active=True,
headline=headline,
slug="a",
author="Jane Austen",
)
year = pub_date.strftime("%Y")
month = pub_date.strftime("%b").lower()
day = pub_date.strftime("%d")
for testcase in [
{
"view": "weblog:archive-year",
"kwargs": {"year": year},
"header": "<h1>2005 archive</h1>",
},
{
"view": "weblog:archive-month",
"kwargs": {"year": year, "month": month},
"header": "<h1>July 2005 archive</h1>",
},
{
"view": "weblog:archive-day",
"kwargs": {"year": year, "month": month, "day": day},
"header": "<h1>July 21 archive</h1>",
},
]:
with self.subTest(view=testcase["view"]):
response = self.client.get(
reverse(testcase["view"], kwargs=testcase["kwargs"])
)
self.assertEqual(response.status_code, 200)
self.assertContains(response, testcase["header"])
self.assertContains(response, headline)


@override_settings(
# Caching middleware is added in the production settings file;
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/templates/blog/entry_archive_day.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

{% block title %}{{ day|date:"MONTH_DAY_FORMAT" }} | {% translate "Weblog" %}{% endblock %}

{% block og_title %}{% blocktranslate %}Django news: {{ day|date:"MONTH_DAY_FORMAT" }} archive{% endblocktranslate %}{% endblock %}
{% block og_title %}{% blocktranslate with day=day|date:"MONTH_DAY_FORMAT" %}Django news: {{ day }} archive{% endblocktranslate %}{% endblock %}

{% block content %}

<h1>{% blocktranslate %}{{ day|date:"MONTH_DAY_FORMAT" }} archive{% endblocktranslate %}</h1>
<h1>{% blocktranslate with day=day|date:"MONTH_DAY_FORMAT" %}{{ day }} archive{% endblocktranslate %}</h1>

<ul class="list-news">

Expand Down
4 changes: 2 additions & 2 deletions djangoproject/templates/blog/entry_archive_month.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

{% block title %}{{ month|date:"YEAR_MONTH_FORMAT" }} | {% translate "Weblog" %}{% endblock %}

{% block og_title %}{% blocktranslate %}Django news: {{ month|date:"YEAR_MONTH_FORMAT" }} archive{% endblocktranslate %}{% endblock %}
{% block og_title %}{% blocktranslate with month=month|date:"YEAR_MONTH_FORMAT" %}Django news: {{ month }} archive{% endblocktranslate %}{% endblock %}

{% block content %}

<h1>{% blocktranslate %}{{ month|date:"YEAR_MONTH_FORMAT" }} archive{% endblocktranslate %}</h1>
<h1>{% blocktranslate with month=month|date:"YEAR_MONTH_FORMAT" %}{{ month }} archive{% endblocktranslate %}</h1>

<ul class="list-news">

Expand Down