-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Don't depend of enabled pdf/epub to show downloads #5502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,3 @@ | ||||||
# -*- coding: utf-8 -*- | ||||||
|
||||||
"""Models for the builds app.""" | ||||||
|
||||||
import datetime | ||||||
|
@@ -258,32 +256,25 @@ def get_subdomain_url(self): | |||||
def get_downloads(self, pretty=False): | ||||||
project = self.project | ||||||
data = {} | ||||||
if pretty: | ||||||
if project.has_pdf(self.slug): | ||||||
data['PDF'] = project.get_production_media_url('pdf', self.slug) | ||||||
if project.has_htmlzip(self.slug): | ||||||
data['HTML'] = project.get_production_media_url( | ||||||
'htmlzip', | ||||||
self.slug, | ||||||
) | ||||||
if project.has_epub(self.slug): | ||||||
data['Epub'] = project.get_production_media_url( | ||||||
'epub', | ||||||
self.slug, | ||||||
) | ||||||
else: | ||||||
if project.has_pdf(self.slug): | ||||||
data['pdf'] = project.get_production_media_url('pdf', self.slug) | ||||||
if project.has_htmlzip(self.slug): | ||||||
data['htmlzip'] = project.get_production_media_url( | ||||||
'htmlzip', | ||||||
self.slug, | ||||||
) | ||||||
if project.has_epub(self.slug): | ||||||
data['epub'] = project.get_production_media_url( | ||||||
'epub', | ||||||
self.slug, | ||||||
) | ||||||
|
||||||
def prettify(k): | ||||||
return k if pretty else k.lower() | ||||||
|
||||||
if project.has_pdf(self.slug): | ||||||
data[prettify('PDF')] = project.get_production_media_url( | ||||||
'pdf', | ||||||
self.slug, | ||||||
) | ||||||
if project.has_htmlzip(self.slug): | ||||||
data[prettify('HTML')] = project.get_production_media_url( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I believe this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I just realized that when prettify was set, we named this to html instead of htmlzip. I need to see if we use this in the footer api, or maybe it's safe to rename the template. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We currently use the name So, it's safe to rename this in the template There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
'htmlzip', | ||||||
self.slug, | ||||||
) | ||||||
if project.has_epub(self.slug): | ||||||
data[prettify('Epub')] = project.get_production_media_url( | ||||||
'epub', | ||||||
self.slug, | ||||||
) | ||||||
return data | ||||||
|
||||||
def get_conf_py_path(self): | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code was duplicates, just refactored it to something simpler