File tree 3 files changed +12
-11
lines changed 3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ def get_version_compare_data(project, base_version=None):
26
26
:param base_version: We assert whether or not the base_version is also the
27
27
highest version in the resulting "is_highest" value.
28
28
"""
29
- versions_qs = Version .internal .public (project = project )
29
+ versions_qs = (
30
+ Version .internal .public (project = project )
31
+ .filter (built = True , active = True )
32
+ )
30
33
31
34
# Take preferences over tags only if the project has at least one tag
32
35
if versions_qs .filter (type = TAG ).exists ():
@@ -46,7 +49,7 @@ def get_version_compare_data(project, base_version=None):
46
49
if highest_version_obj :
47
50
# Never link to the dashboard,
48
51
# 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 )
52
+ ret_val ['url' ] = highest_version_obj .get_absolute_url ()
50
53
ret_val ['slug' ] = highest_version_obj .slug
51
54
if base_version and base_version .slug != LATEST :
52
55
try :
Original file line number Diff line number Diff line change @@ -289,13 +289,8 @@ def commit_name(self):
289
289
)
290
290
return self .identifier
291
291
292
- def get_absolute_url (self , link_to_dashboard = True ):
293
- """
294
- Get absolute url to the docs of the version.
295
-
296
- :param link_to_dashboard: If `False` we never try to link to the dashboard,
297
- we link to the docs even if they result in a 404.
298
- """
292
+ def get_absolute_url (self ):
293
+ """Get absolute url to the docs of the version."""
299
294
# Hack external versions for now.
300
295
# TODO: We can integrate them into the resolver
301
296
# but this is much simpler to handle since we only link them a couple places for now
@@ -305,7 +300,7 @@ def get_absolute_url(self, link_to_dashboard=True):
305
300
f'{ self .project .slug } /{ self .slug } /index.html'
306
301
return url
307
302
308
- if not self .built and not self .uploaded and link_to_dashboard :
303
+ if not self .built and not self .uploaded :
309
304
return reverse (
310
305
'project_version_detail' ,
311
306
kwargs = {
Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ class TestVersionCompareFooter(TestCase):
124
124
125
125
def setUp (self ):
126
126
self .pip = Project .objects .get (slug = 'pip' )
127
+ self .pip .versions .update (built = True )
127
128
128
129
def test_highest_version_from_stable (self ):
129
130
base_version = self .pip .get_stable_version ()
@@ -150,7 +151,7 @@ def test_highest_version_from_lower(self):
150
151
self .assertDictEqual (valid_data , returned_data )
151
152
152
153
def test_highest_version_from_latest (self ):
153
- Version .objects .create_latest (project = self .pip )
154
+ Version .objects .create_latest (project = self .pip , built = True )
154
155
base_version = self .pip .versions .get (slug = LATEST )
155
156
valid_data = {
156
157
'project' : 'Version 0.8.1 of Pip (19)' ,
@@ -177,6 +178,7 @@ def test_highest_version_over_branches(self):
177
178
identifier = '1.0.0' ,
178
179
type = TAG ,
179
180
active = True ,
181
+ built = True ,
180
182
)
181
183
182
184
base_version = self .pip .versions .get (slug = '0.8.1' )
@@ -221,6 +223,7 @@ def test_highest_version_without_tags(self):
221
223
identifier = '2.0.0' ,
222
224
type = BRANCH ,
223
225
active = True ,
226
+ built = True ,
224
227
)
225
228
valid_data = {
226
229
'project' : 'Version 2.0.0 of Pip ({})' .format (version .pk ),
You can’t perform that action at this time.
0 commit comments