From: Frédéric Perrin Date: Fri, 30 Sep 2016 22:57:35 +0000 (+0000) Subject: On the author page, don't display the author notes for each quote X-Git-Url: http://gitweb.fperrin.net/?p=djsite.git;a=commitdiff_plain;h=1403f44199bde09f56e466285e00462e88e344fd On the author page, don't display the author notes for each quote That's just silly... Likewise on the one quote page, display the author notes only once --- diff --git a/quotes/templates/quotes/author.html b/quotes/templates/quotes/author.html index b09befc..60dbafa 100644 --- a/quotes/templates/quotes/author.html +++ b/quotes/templates/quotes/author.html @@ -11,8 +11,7 @@

All the quotes for {{ author.name }}:

{% for quote in author.quote_set.all %} - {% include "quotes/display.html" with quote=quote %} + {% include "quotes/display.html" with quote=quote skip_author_notes=True %} {% endfor %} - {% endblock %} diff --git a/quotes/templates/quotes/display.html b/quotes/templates/quotes/display.html index 2e09b35..8901085 100644 --- a/quotes/templates/quotes/display.html +++ b/quotes/templates/quotes/display.html @@ -20,6 +20,10 @@

+ {% if not skip_author_notes %} + {% include "quotes/author_notes.html" with author=quote.author %} + {% endif %} + {% if quote.tags.all %}

Tags: diff --git a/quotes/templates/quotes/onequote.html b/quotes/templates/quotes/onequote.html index 25f7971..5d5177c 100644 --- a/quotes/templates/quotes/onequote.html +++ b/quotes/templates/quotes/onequote.html @@ -6,6 +6,4 @@ {% include "quotes/display.html" with quote=quote %} -{% include "quotes/author_notes.html" with author=quote.author %} - {% endblock %} diff --git a/quotes/tests.py b/quotes/tests.py index 556e925..2a7bc45 100644 --- a/quotes/tests.py +++ b/quotes/tests.py @@ -66,3 +66,15 @@ class ViewsTest(TestCase): self.assertEqual(response.status_code, 200) self.assertFalse('Quote01, two tags' in response.content) self.assertTrue('Quote02' in response.content) + + def test_view_author_notes_once(self): + # check that on the per-author view, the author notes aren't display + # for every quote + a = Author.objects.filter(name="Author with notes") + self.assertEqual(a.count(), 1) + a = a[0] + + c = Client() + response = c.get('/quotes/author/%s/' % a.id) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.content.count("Some notes"), 1)