Skip to content

Commit cabe0c9

Browse files
committed
Never link to the dashboard from the footer
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.
1 parent f30eb28 commit cabe0c9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

readthedocs/api/v2/views/footer_views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def get_version_compare_data(project, base_version=None):
4444
'is_highest': True,
4545
}
4646
if highest_version_obj:
47-
ret_val['url'] = highest_version_obj.get_absolute_url()
47+
# Never link to the dashboard,
48+
# users reading the docs may don't have access to the dashboard.
49+
ret_val['url'] = highest_version_obj.get_absolute_url(link_to_dashboard=False)
4850
ret_val['slug'] = highest_version_obj.slug
4951
if base_version and base_version.slug != LATEST:
5052
try:

readthedocs/builds/models.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
from readthedocs.projects.models import APIProject, Project
7878
from readthedocs.projects.version_handling import determine_stable_version
7979

80-
8180
log = logging.getLogger(__name__)
8281

8382

@@ -289,7 +288,13 @@ def commit_name(self):
289288
)
290289
return self.identifier
291290

292-
def get_absolute_url(self):
291+
def get_absolute_url(self, link_to_dashboard=True):
292+
"""
293+
Get absolute url to the docs of the version.
294+
295+
:param link_to_dashboard: If `False` we never try to link to the dashboard,
296+
we link to the docs even if they result in a 404.
297+
"""
293298
# Hack external versions for now.
294299
# TODO: We can integrate them into the resolver
295300
# but this is much simpler to handle since we only link them a couple places for now
@@ -299,7 +304,7 @@ def get_absolute_url(self):
299304
f'{self.project.slug}/{self.slug}/index.html'
300305
return url
301306

302-
if not self.built and not self.uploaded:
307+
if not self.built and not self.uploaded and link_to_dashboard:
303308
return reverse(
304309
'project_version_detail',
305310
kwargs={

0 commit comments

Comments
 (0)