Skip to content

List only built versions on the footer #6137

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
stsewd opened this issue Sep 5, 2019 · 3 comments · Fixed by #6353
Closed

List only built versions on the footer #6137

stsewd opened this issue Sep 5, 2019 · 3 comments · Fixed by #6353
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code

Comments

@stsewd
Copy link
Member

stsewd commented Sep 5, 2019

When a version is built=False our code links to the version detail page

if not self.built and not self.uploaded:
return reverse(
'project_version_detail',
kwargs={
'project_slug': self.project.slug,
'version_slug': self.slug,
},

This method gets called from sort_version_aware, here we are passing all active versions (including not built).

def ordered_active_versions(self, **kwargs):
"""
Get all active versions, sorted.
:param kwargs: All kwargs are passed down to the
`Version.internal.public` queryset.
"""
from readthedocs.builds.models import Version
kwargs.update(
{
'project': self,
'only_active': True,
},
)
versions = (
Version.internal.public(**kwargs)
.select_related(
'project',
'project__main_language_project',
)
.prefetch_related(
Prefetch(
'project__superprojects',
ProjectRelationship.objects.all().select_related('parent'),
to_attr='_superprojects',
),
Prefetch(
'project__domains',
Domain.objects.filter(canonical=True),
to_attr='_canonical_domains',
),
)
)
return sort_version_aware(versions)

This is a problem in .com, where we don't have access to that URLCONF, so reverse doesn't work.

I'm thinking two options:

  1. Only list built versions, this is modify this method and add a filter (this method is only used in the footer).

def ordered_active_versions(self, **kwargs):

  1. Only change this in .com, adding a new kwarg to .public (only_builts=False)

I'm more inclined to 1, so we affect .org and .com, giving a link to the dashboard to a user that doesn't have permissions doesn't look correct.

@stsewd stsewd added the Needed: design decision A core team decision is required label Sep 5, 2019
@humitos
Copy link
Member

humitos commented Sep 5, 2019

Just want to note a use case of this.

Listing "active but not built versions" in the footer is kind of a hidden feature. Why? It allows people to list all the supported versions in the footer and create a Redirect pointing to a different hosting platform for old versions for example.

So, 1.x and 2.x are hosted at Read the Docs, but 0.8.x and 0.9.x are hosted in a different platform. You active=True the fourth of them and create two Redirects for 0.8.x and 0.9.x.

I've used this "hidden feature" for a user already.

@stsewd
Copy link
Member Author

stsewd commented Sep 5, 2019

@humitos but when the version is built=False it links to the dashboard, so the redirect doesn't work there.

@ericholscher
Copy link
Member

ericholscher commented Nov 6, 2019

Yea, I think linking to the dashboard doesn't make sense in the context of the footer. I'm happy to update the link to simply go to the docs page, and have it 404 if it isn't built. That enables the redirect logic that @humitos was talking about, and linking the dashboard is not useful for users basically ever when they're in the docs page.

@stsewd stsewd added Accepted Accepted issue on our roadmap Improvement Minor improvement to code and removed Needed: design decision A core team decision is required labels Nov 6, 2019
stsewd added a commit to stsewd/readthedocs.org that referenced this issue Nov 6, 2019
Closes readthedocs#6137

We use the `get_absolute_url` in other parts of the code
where it makes sense to link to the dashboard.
So I'm adding an additional parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants