]> gitweb.fperrin.net Git - djsite.git/commitdiff
On the author page, don't display the author notes for each quote
authorFrédéric Perrin <frederic.perrin@resel.fr>
Fri, 30 Sep 2016 22:57:35 +0000 (22:57 +0000)
committerFrédéric Perrin <frederic.perrin@resel.fr>
Fri, 30 Sep 2016 22:57:35 +0000 (22:57 +0000)
That's just silly...
Likewise on the one quote page, display the author notes only once

quotes/templates/quotes/author.html
quotes/templates/quotes/display.html
quotes/templates/quotes/onequote.html
quotes/tests.py

index b09befc1d7f8797fa80d729d4007992c93c1db87..60dbafa577c45b4cf83ff3ef9354d096b745b5ff 100644 (file)
@@ -11,8 +11,7 @@
 <p>All the quotes for {{ author.name }}:<p>
 
 {% for quote in author.quote_set.all %}
 <p>All the quotes for {{ author.name }}:<p>
 
 {% 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 %}
 
 {% endfor %}
 
-
 {% endblock %}
 {% endblock %}
index 2e09b3540a957c03c4613b1ba4fcc72a72eef490..89010857aba943beb62d6a2f3ff65b904e437a99 100644 (file)
        </span>
       </p>
 
        </span>
       </p>
 
+      {% if not skip_author_notes %}
+        {% include "quotes/author_notes.html" with author=quote.author %}
+      {% endif %}
+
       {% if quote.tags.all %}
       <p class="tags">
        Tags:
       {% if quote.tags.all %}
       <p class="tags">
        Tags:
index 25f7971ab62e8dc2b4ed98caeb8194c60bb3a268..5d5177cae2a8b414714f2a80c2cd3117b5fb1a8e 100644 (file)
@@ -6,6 +6,4 @@
 
 {% include "quotes/display.html" with quote=quote %}
 
 
 {% include "quotes/display.html" with quote=quote %}
 
-{% include "quotes/author_notes.html" with author=quote.author %}
-
 {% endblock %}
 {% endblock %}
index 556e9252c3377477911b077da4e64315b8f067b9..2a7bc4502ae84b04ce160ced0f6290c2bf03d6e7 100644 (file)
@@ -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)
         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)