Skip to content

Commit d43b16f

Browse files
committed
Only show external build tab if external builds are available
1 parent 8b320d6 commit d43b16f

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

readthedocs/builds/views.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ def get_context_data(self, **kwargs):
119119

120120
class ExternalBuildList(BuildBase, ListView):
121121
template_name = 'builds/external_build_list.html'
122+
allow_empty = False
122123

123124
def get_queryset(self):
124-
# this is used to include only internal version
125+
# this is used to include only external version
125126
# builds in the build list page
126127
self.project_slug = self.kwargs.get('project_slug', None)
127128
self.project = get_object_or_404(

readthedocs/projects/models.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from taggit.managers import TaggableManager
2121

2222
from readthedocs.api.v2.client import api
23-
from readthedocs.builds.constants import LATEST, STABLE, INTERNAL
23+
from readthedocs.builds.constants import LATEST, STABLE, INTERNAL, EXTERNAL
2424
from readthedocs.core.resolver import resolve, resolve_domain
2525
from readthedocs.core.utils import broadcast, slugify
2626
from readthedocs.projects import constants
@@ -1115,6 +1115,10 @@ def environment_variables(self):
11151115
for variable in self.environmentvariable_set.all()
11161116
}
11171117

1118+
@property
1119+
def has_external_builds(self):
1120+
return self.builds(manager=EXTERNAL).exists()
1121+
11181122

11191123
class APIProject(Project):
11201124

readthedocs/rtd_tests/tests/test_project.py

+7
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ def test_get_external_builds_url(self):
172172
f'/projects/{self.pip.slug}/builds/pr/'
173173
)
174174

175+
def test_project_has_external_builds(self):
176+
external_build = Build.objects.create(
177+
project=self.pip,
178+
version=self.external_version,
179+
)
180+
self.assertTrue(self.pip.has_external_builds)
181+
175182

176183
class TestProjectTranslations(ProjectMixin, TestCase):
177184

readthedocs/templates/core/project_bar_base.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ <h1>
4545

4646
<li class="{{ builds_active }}"><a href="{{ project.get_builds_url }}">{% trans "Builds" %}</a></li>
4747

48-
<li class="{{ external_builds_active }}"><a href="{{ project.get_external_builds_url }}">{% trans "External Builds" %}</a></li>
48+
{% if project.has_external_builds %}
49+
<li class="{{ external_builds_active }}"><a href="{{ project.get_external_builds_url }}">{% trans "External Builds" %}</a></li>
50+
{% endif %}
4951

5052
<li class="{{ versions_active }}"><a href="{% url "project_version_list" project.slug %}">{% trans "Versions" %}</a></li>
5153

0 commit comments

Comments
 (0)