Skip to content

Commit

Permalink
Merge pull request #6276 from readthedocs/davidfischer/version-trunca…
Browse files Browse the repository at this point in the history
…ted-message

Show message if version list truncated
  • Loading branch information
humitos committed Feb 19, 2020
2 parents 60fb1a3 + d21dd25 commit 098db3d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion readthedocs/projects/views/public.py
Expand Up @@ -367,6 +367,8 @@ def project_versions(request, project_slug):
Shows the available versions and lets the user choose which ones to build.
"""
max_inactive_versions = 100

project = get_object_or_404(
Project.objects.protected(request.user),
slug=project_slug,
Expand All @@ -385,7 +387,8 @@ def project_versions(request, project_slug):
version_filter = request.GET.get('version_filter', '')
if version_filter:
inactive_versions = inactive_versions.filter(verbose_name__icontains=version_filter)
inactive_versions = inactive_versions[:100]
total_inactive_versions_count = inactive_versions.count()
inactive_versions = inactive_versions[:max_inactive_versions]

# If there's a wiped query string, check the string against the versions
# list and display a success message. Deleting directories doesn't know how
Expand All @@ -405,6 +408,8 @@ def project_versions(request, project_slug):
'inactive_versions': inactive_versions,
'active_versions': active_versions,
'project': project,
'max_inactive_versions': max_inactive_versions,
'total_inactive_versions_count': total_inactive_versions_count,
},
)

Expand Down
11 changes: 11 additions & 0 deletions readthedocs/templates/projects/project_version_list.html
Expand Up @@ -134,8 +134,19 @@ <h1>{% trans "Activate a version" %}</h1>
</div>
{% endif %}



</div>
</div>

{% if total_inactive_versions_count > max_inactive_versions %}
<p>
{% blocktrans trimmed %}
Showing the first {{ max_inactive_versions }} of {{ total_inactive_versions_count }} inactive versions.</a>.
{% endblocktrans %}
</p>
{% endif %}

{% endif %}

</div>
Expand Down

0 comments on commit 098db3d

Please sign in to comment.