File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,9 @@ def get_version_compare_data(project, base_version=None):
44
44
'is_highest' : True ,
45
45
}
46
46
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 )
48
50
ret_val ['slug' ] = highest_version_obj .slug
49
51
if base_version and base_version .slug != LATEST :
50
52
try :
Original file line number Diff line number Diff line change 77
77
from readthedocs .projects .models import APIProject , Project
78
78
from readthedocs .projects .version_handling import determine_stable_version
79
79
80
-
81
80
log = logging .getLogger (__name__ )
82
81
83
82
@@ -289,7 +288,13 @@ def commit_name(self):
289
288
)
290
289
return self .identifier
291
290
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
+ """
293
298
# Hack external versions for now.
294
299
# TODO: We can integrate them into the resolver
295
300
# 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):
299
304
f'{ self .project .slug } /{ self .slug } /index.html'
300
305
return url
301
306
302
- if not self .built and not self .uploaded :
307
+ if not self .built and not self .uploaded and link_to_dashboard :
303
308
return reverse (
304
309
'project_version_detail' ,
305
310
kwargs = {
You can’t perform that action at this time.
0 commit comments