Skip to content

Commit 4ee2936

Browse files
authored
Merge pull request #6224 from readthedocs/davidfischer/improve-version-listview
Improve the version listview
2 parents 7fcdf5c + 50afb57 commit 4ee2936

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

readthedocs/projects/views/public.py

+7
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,14 @@ def project_versions(request, project_slug):
284284
only_active=False,
285285
)
286286
active_versions = versions.filter(active=True)
287+
288+
# Limit inactive versions in case a project has a large number of branches or tags
289+
# Filter inactive versions based on the query string
287290
inactive_versions = versions.filter(active=False)
291+
version_filter = request.GET.get('version_filter', '')
292+
if version_filter:
293+
inactive_versions = inactive_versions.filter(verbose_name__icontains=version_filter)
294+
inactive_versions = inactive_versions[:100]
288295

289296
# If there's a wiped query string, check the string against the versions
290297
# list and display a success message. Deleting directories doesn't know how

readthedocs/templates/projects/project_version_list.html

+17-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,22 @@ <h1>{% trans "Active Versions" %}</h1>
7878

7979
{% if inactive_versions %}
8080
<div class="module-header">
81-
<h1>{% trans "Inactive Versions" %}</h1>
81+
<h1>{% trans "Activate a version" %}</h1>
82+
<p>{% trans "Active versions are built whenever new code is pushed to that branch or tag." %}</p>
83+
</div>
84+
85+
{# Version search #}
86+
<div class="wide-search-bar">
87+
<div class="wide-search-bar-wrapper clearfix">
88+
<form action="." method="GET">
89+
<div class="text-input-wrapper">
90+
<input type="text" name="version_filter" value="{{ request.GET.version_filter }}" placeholder="1.0, 2.0, devel">
91+
</div>
92+
<div class="submit-input-wrapper">
93+
<input type="submit" value="{% trans 'Filter Inactive Versions' %}">
94+
</div>
95+
</form>
96+
</div>
8297
</div>
8398

8499
<div class="module-list">
@@ -104,7 +119,7 @@ <h1>{% trans "Inactive Versions" %}</h1>
104119

105120
{% if request.user|is_admin:project %}
106121
<ul class="module-item-menu">
107-
<li><a href="{% url "project_version_detail" project.slug version.slug %}">{% trans "Edit" %}</a></li>
122+
<li><a href="{% url "project_version_detail" project.slug version.slug %}">{% trans "Activate" %}</a></li>
108123
</ul>
109124
{% endif %}
110125

0 commit comments

Comments
 (0)