move download count display to work infobox and rh_tools
parent
de442c8f63
commit
a2606b2e08
|
@ -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')
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
<img src="{{ ebook.rights_badge }}" alt="{{ ebook.rights}}" title="{{ ebook.rights}}" /></a>
|
||||
<a href="{% url ebook ebook.id %}"><img src="/static/images/{{ ebook.format }}32.png" height="32" alt="{{ ebook.format }}" title="{{ ebook.format }}" /></a>
|
||||
<a href="{% url ebook ebook.id %}">{{ ebook.format }}</a>
|
||||
<span> ( {{ ebook.download_count }} downloads ) </span>
|
||||
{% ifequal ebook.format 'mobi' %} (use for Kindle){% endifequal %}
|
||||
{% ifequal ebook.format 'epub' %} (use for Nook, Apple, Sony){% endifequal %}
|
||||
{% if not forloop.last %}<br /><br />{% endif %}
|
||||
|
@ -56,7 +55,6 @@
|
|||
<img src="{{ ebook.rights_badge }}" alt="{{ ebook.rights}}" title="{{ ebook.rights}}" /></a>
|
||||
<a href="{% url ebook ebook.id %}"><img src="/static/images/{{ ebook.format }}32.png" height="32" alt="{{ ebook.format }} at {{ebook.provider}}" title="{{ ebook.format }} at {{ebook.provider}}" /></a>
|
||||
<a href="{% url ebook ebook.id %}">{{ ebook.format }} at {{ebook.provider}}</a>
|
||||
<span> ( {{ ebook.download_count }} downloads ) </span>
|
||||
{% ifequal ebook.format 'mobi' %} (use for Kindle){% endifequal %}
|
||||
{% ifequal ebook.format 'epub' %} (use for Nook, Apple, Sony){% endifequal %}
|
||||
{% if not forloop.last %}<br /><br />{% endif %}
|
||||
|
|
|
@ -127,6 +127,18 @@ Any questions not covered here? Please email us at <a href="mailto:rights@gluej
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if claim.work.first_ebook %}
|
||||
<h4> Ebooks for this work </h3>
|
||||
<div class="work_campaigns">
|
||||
<ul>
|
||||
{% for ebook in claim.work.ebooks %}
|
||||
<li> edition #{{ebook.edition.id}} {{ ebook.format }}
|
||||
{{ ebook.download_count }} downloads
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
|
|
|
@ -138,6 +138,11 @@
|
|||
{{ wishers }} Ungluers have
|
||||
{% endif %} wished for this Work
|
||||
</div>
|
||||
{% if work.first_ebook %}
|
||||
<div class="pledged-info">
|
||||
Downloaded {{ work.download_count }} times.
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endifequal %}
|
||||
<div class="find-book">
|
||||
<label>Learn more at...</label>
|
||||
|
|
Loading…
Reference in New Issue