add work.formats()

pull/1/head
eric 2016-05-16 16:43:03 -04:00
parent f662920c2a
commit 66c0d84029
2 changed files with 9 additions and 1 deletions

View File

@ -1360,6 +1360,14 @@ class Work(models.Model):
def pdffiles(self):
return EbookFile.objects.filter(edition__work=self, format='pdf').exclude(file='').order_by('-created')
def formats(self):
fmts=[]
for fmt in ['pdf', 'epub', 'mobi', 'html']:
for ebook in self.ebooks().filter(format=fmt):
fmts.append(fmt)
break
return fmts
def make_ebooks_from_ebfs(self, add_ask=True):
# either the ebf has been uploaded or a created (perhaps an ask was added or mobi generated)
if self.last_campaign().type != THANKS: # just to make sure that ebf's can be unglued by mistake

View File

@ -6,7 +6,7 @@
{% load lib_acqs %}
{% block title %}—
{% if work.is_free %}
{{ work.title }} is a Free eBook. {% if work.first_pdf %}[PDF]{% endif %}{% if work.first_epub %}[EPUB, MOBI]{% endif %}
{{ work.title }} is a Free eBook. {% for fmt in work.formats %}[{{ fmt }}]{% endfor %}
{% else %}
Help us make {{ work.title }} a Free eBook!
{% endif %}{% ifequal action 'editions' %} All Editions{% endifequal %}