From a2606b2e081226dc6d356dafa984f5251008c170 Mon Sep 17 00:00:00 2001 From: eric Date: Sat, 20 Apr 2013 10:08:10 -0400 Subject: [PATCH] move download count display to work infobox and rh_tools --- core/models.py | 7 +++++++ core/tests.py | 1 + frontend/templates/download.html | 2 -- frontend/templates/rh_tools.html | 12 ++++++++++++ frontend/templates/work.html | 5 +++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/core/models.py b/core/models.py index 474c8f01..879de68c 100755 --- a/core/models.py +++ b/core/models.py @@ -754,6 +754,13 @@ class Work(models.Model): def ebooks(self): return Ebook.objects.filter(edition__work=self).order_by('-created') + @property + def download_count(self): + dlc=0 + for ebook in self.ebooks(): + dlc += ebook.download_count + return dlc + def first_pdf(self): return self.first_ebook('pdf') diff --git a/core/tests.py b/core/tests.py index 2c6daa73..72457176 100755 --- a/core/tests.py +++ b/core/tests.py @@ -299,6 +299,7 @@ class BookLoaderTests(TestCase): ebook_pdf.increment() updated_ebook = Ebook.objects.get(pk=ebook_pdf.pk) self.assertEqual(int(updated_ebook.download_count), 1) + self.assertEqual(int(edition.work.download_count), 1) def test_add_no_ebook(self): # this edition lacks an ebook, but we should still be able to load it diff --git a/frontend/templates/download.html b/frontend/templates/download.html index 82787aa3..ad39582e 100644 --- a/frontend/templates/download.html +++ b/frontend/templates/download.html @@ -36,7 +36,6 @@ {{ ebook.rights}} {{ ebook.format }} {{ ebook.format }} - ( {{ ebook.download_count }} downloads ) {% ifequal ebook.format 'mobi' %} (use for Kindle){% endifequal %} {% ifequal ebook.format 'epub' %} (use for Nook, Apple, Sony){% endifequal %} {% if not forloop.last %}

{% endif %} @@ -56,7 +55,6 @@ {{ ebook.rights}} {{ ebook.format }} at {{ebook.provider}} {{ ebook.format }} at {{ebook.provider}} - ( {{ ebook.download_count }} downloads ) {% ifequal ebook.format 'mobi' %} (use for Kindle){% endifequal %} {% ifequal ebook.format 'epub' %} (use for Nook, Apple, Sony){% endifequal %} {% if not forloop.last %}

{% endif %} diff --git a/frontend/templates/rh_tools.html b/frontend/templates/rh_tools.html index 16b3942f..b8ec830d 100644 --- a/frontend/templates/rh_tools.html +++ b/frontend/templates/rh_tools.html @@ -127,6 +127,18 @@ Any questions not covered here? Please email us at + + + {% endif %} {% endfor %} diff --git a/frontend/templates/work.html b/frontend/templates/work.html index b3081ee6..c2621bb6 100644 --- a/frontend/templates/work.html +++ b/frontend/templates/work.html @@ -138,6 +138,11 @@ {{ wishers }} Ungluers have {% endif %} wished for this Work + {% if work.first_ebook %} +
+ Downloaded {{ work.download_count }} times. +
+ {% endif %} {% endifequal %}