Skip to content

Version page should show build status + not being able to pick a non-built doc #5169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Empty file.
20 changes: 20 additions & 0 deletions readthedocs/builds/templatetags/builds_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-

from django import template


register = template.Library()


@register.simple_tag
def is_latest_built_success(version):
"""
Checks the build status of the passed version.

Returns true if the latest build for the ``version``
is success else returns false. Returns None if no
build is found for the given version.
"""
res = version.builds.all().order_by('-date').values_list('success', flat=True)
if res.exists():
return res.first()
11 changes: 11 additions & 0 deletions readthedocs/templates/core/project_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% load privacy_tags %}
{% load gravatar %}
{% load projects_tags %}
{% load builds_tags %}

<div id="project_details">
<div class="wrapper">
Expand Down Expand Up @@ -32,6 +33,16 @@ <h3>{% trans "Versions" %}</h3>
{% if request.user in project.users.all %}
<span class="right-menu quiet">{{ version.get_privacy_level_display }}</span>
{% endif %}
{% if request.user|is_admin:project %}
<span class="right-menu quiet">
{% is_latest_built_success version as is_success %}
{% if is_success %}
<span class="build-state build-state-passing">{% trans "passing" %}</span>
{% else %}
<span class="build-state build-state-failing">{% trans "failing" %}</span>
{% endif %}
</span>
{% endif %}
</a>
{% else %}
<a class="module-item-title" href="{{ version.project.get_builds_url }}">
Expand Down