Skip to content

Show pdf in yml-enabled setup if this format enabled #2638

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
from readthedocs.vcs_support.backends import backend_cls
from readthedocs.vcs_support.utils import Lock, NonBlockingLock

from readthedocs.doc_builder.config import load_yaml_config

if sys.version_info > (3,):
# pylint: disable=import-error
from urllib.parse import urlparse
Expand Down Expand Up @@ -570,8 +572,15 @@ def has_aliases(self):
return self.aliases.exists()

def has_pdf(self, version_slug=LATEST):
version = self.versions.filter(slug=version_slug).first()
if not self.enable_pdf_build:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably just remove the initial check on this, and simply look for the file existing. I believe the issue is that we'd have PDF's sitting on disk that were stale, so we added this flag. Another option is to set this flag in the database based off the YAML file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericholscher, are you about this check, on L573? I think, I have tried this, that breaks tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, the tests would need to be changed, as it would be a change in how things work. Perhaps the easiest update would be to actually update the database for a project from the YAML file on build. I'd want @agjohnson's thoughts on that though, because it is a weird UX. Perhaps if we detect YAML we can hide the fields on the web UI, and update them from the YAML for consistency.

return False
try:
config = load_yaml_config(version)
except AttributeError:
return False
else:
if 'pdf' not in config.formats:
return False
return os.path.exists(self.get_production_media_path(
type_='pdf', version_slug=version_slug))

Expand Down