From 968c2881573aace79e9c3b44a71f1f9fcd9791ee Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Thu, 24 Jan 2019 23:12:08 +0530 Subject: [PATCH 1/7] add some small features --- readthedocs/projects/forms.py | 2 +- readthedocs/templates/core/project_details.html | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/readthedocs/projects/forms.py b/readthedocs/projects/forms.py index ca55e456606..ac78570feca 100644 --- a/readthedocs/projects/forms.py +++ b/readthedocs/projects/forms.py @@ -444,7 +444,7 @@ def build_versions_form(project): active = versions_qs.filter(active=True) if active.exists(): active = sort_version_aware(active) - choices = [(version.slug, version.verbose_name) for version in active] + choices = [(version.slug, version.verbose_name) for version in active if version.built] attrs['default-version'] = forms.ChoiceField( label=_('Default Version'), choices=choices, diff --git a/readthedocs/templates/core/project_details.html b/readthedocs/templates/core/project_details.html index 205d296cd2a..c4020885914 100644 --- a/readthedocs/templates/core/project_details.html +++ b/readthedocs/templates/core/project_details.html @@ -41,6 +41,15 @@

{% trans "Versions" %}

{% if request.user|is_admin:project %} {% endif %} From c20509ebf2c720a96f8f7f26c17f70af204351c1 Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Sat, 2 Mar 2019 01:13:30 +0530 Subject: [PATCH 2/7] use template tags --- readthedocs/builds/templatetags/__init__.py | 0 readthedocs/builds/templatetags/builds_tags.py | 18 ++++++++++++++++++ .../templates/core/project_details.html | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 readthedocs/builds/templatetags/__init__.py create mode 100644 readthedocs/builds/templatetags/builds_tags.py diff --git a/readthedocs/builds/templatetags/__init__.py b/readthedocs/builds/templatetags/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/readthedocs/builds/templatetags/builds_tags.py b/readthedocs/builds/templatetags/builds_tags.py new file mode 100644 index 00000000000..0047450e323 --- /dev/null +++ b/readthedocs/builds/templatetags/builds_tags.py @@ -0,0 +1,18 @@ +# -*- 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 passed else returns false. + """ + res = version.builds.all().order_by('-date').first().success + return res diff --git a/readthedocs/templates/core/project_details.html b/readthedocs/templates/core/project_details.html index c4020885914..5090dddcfef 100644 --- a/readthedocs/templates/core/project_details.html +++ b/readthedocs/templates/core/project_details.html @@ -3,6 +3,7 @@ {% load privacy_tags %} {% load gravatar %} {% load projects_tags %} +{% load builds_tags %}
@@ -43,7 +44,8 @@

{% trans "Versions" %}

  • {% trans "Edit" %}
  • - {% if version.built %} + {% is_latest_built_success version as is_success %} + {% if is_success %} {% trans "passing" %} {% else %} {% trans "failing" %} From ca1ff6ef1a06eb3485a30a1d72e87f057d1203d0 Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Sat, 2 Mar 2019 01:32:10 +0530 Subject: [PATCH 3/7] add if --- readthedocs/builds/templatetags/builds_tags.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/readthedocs/builds/templatetags/builds_tags.py b/readthedocs/builds/templatetags/builds_tags.py index 0047450e323..3327c2edb98 100644 --- a/readthedocs/builds/templatetags/builds_tags.py +++ b/readthedocs/builds/templatetags/builds_tags.py @@ -14,5 +14,6 @@ def is_latest_built_success(version): Returns true if the latest build for the ``version`` is passed else returns false. """ - res = version.builds.all().order_by('-date').first().success - return res + res = version.builds.all().order_by('-date') + if res.exists(): + return res.first().success From ff822846dc462015a2d9c1362afd2aabdb48dcd3 Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Sat, 2 Mar 2019 01:39:03 +0530 Subject: [PATCH 4/7] edit func doc --- readthedocs/builds/templatetags/builds_tags.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readthedocs/builds/templatetags/builds_tags.py b/readthedocs/builds/templatetags/builds_tags.py index 3327c2edb98..c3c2a7fed74 100644 --- a/readthedocs/builds/templatetags/builds_tags.py +++ b/readthedocs/builds/templatetags/builds_tags.py @@ -12,7 +12,8 @@ def is_latest_built_success(version): Checks the build status of the passed version. Returns true if the latest build for the ``version`` - is passed else returns false. + is success else returns false. Returns None if no + build is found for the given version. """ res = version.builds.all().order_by('-date') if res.exists(): From 83746011bc8c8b801c3b14ea623152ff5d94855f Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Fri, 29 Mar 2019 15:21:04 +0530 Subject: [PATCH 5/7] Add improvements --- media/css/core.css | 1 + readthedocs/builds/templatetags/builds_tags.py | 4 ++-- readthedocs/templates/core/project_details.html | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/media/css/core.css b/media/css/core.css index d07a81ec1c4..402d986c46a 100644 --- a/media/css/core.css +++ b/media/css/core.css @@ -717,6 +717,7 @@ p.build-missing { font-size: .8em; color: #9d9a55; margin: 0 0 3px; } .hide { display: none; } .left { float: left; } .right { float: right; } +.status-middle { margin: 10px 5px 0px 0px; } .right-menu { float: right; margin-right: 132px; } .help_text { color: #999; } .highlighted { background-color: #ee9; padding: 0 1px; margin: 0 1px; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; } diff --git a/readthedocs/builds/templatetags/builds_tags.py b/readthedocs/builds/templatetags/builds_tags.py index c3c2a7fed74..ff4bcfd6f07 100644 --- a/readthedocs/builds/templatetags/builds_tags.py +++ b/readthedocs/builds/templatetags/builds_tags.py @@ -15,6 +15,6 @@ def is_latest_built_success(version): is success else returns false. Returns None if no build is found for the given version. """ - res = version.builds.all().order_by('-date') + res = version.builds.all().order_by('-date').values_list('success', flat=True) if res.exists(): - return res.first().success + return res.first() diff --git a/readthedocs/templates/core/project_details.html b/readthedocs/templates/core/project_details.html index 5090dddcfef..3a9606d64cc 100644 --- a/readthedocs/templates/core/project_details.html +++ b/readthedocs/templates/core/project_details.html @@ -43,7 +43,7 @@

    {% trans "Versions" %}

    • {% trans "Edit" %}
    • - + {% is_latest_built_success version as is_success %} {% if is_success %} {% trans "passing" %} From 41eda6e1e53413cf5a7f0379d491b3b03813f8dd Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Fri, 29 Mar 2019 15:27:19 +0530 Subject: [PATCH 6/7] remove inline css --- media/css/core.css | 1 + readthedocs/templates/core/project_details.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/media/css/core.css b/media/css/core.css index 402d986c46a..8f1ba2e3775 100644 --- a/media/css/core.css +++ b/media/css/core.css @@ -718,6 +718,7 @@ p.build-missing { font-size: .8em; color: #9d9a55; margin: 0 0 3px; } .left { float: left; } .right { float: right; } .status-middle { margin: 10px 5px 0px 0px; } +.status-failing { margin-left: 14px } .right-menu { float: right; margin-right: 132px; } .help_text { color: #999; } .highlighted { background-color: #ee9; padding: 0 1px; margin: 0 1px; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; } diff --git a/readthedocs/templates/core/project_details.html b/readthedocs/templates/core/project_details.html index 3a9606d64cc..021b5a6d8d6 100644 --- a/readthedocs/templates/core/project_details.html +++ b/readthedocs/templates/core/project_details.html @@ -48,7 +48,7 @@

      {% trans "Versions" %}

      {% if is_success %} {% trans "passing" %} {% else %} - {% trans "failing" %} + {% trans "failing" %} {% endif %}
    • From d9651adaeab49d2ceadcc9b2da913e72d89bb4ee Mon Sep 17 00:00:00 2001 From: dojutsu-user Date: Sun, 4 Aug 2019 13:02:16 +0530 Subject: [PATCH 7/7] improvements --- media/css/core.css | 2 -- .../templates/core/project_details.html | 20 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/media/css/core.css b/media/css/core.css index 7f92416641d..206596e1a23 100644 --- a/media/css/core.css +++ b/media/css/core.css @@ -720,8 +720,6 @@ p.build-missing { font-size: .8em; color: #9d9a55; margin: 0 0 3px; } .hide { display: none; } .left { float: left; } .right { float: right; } -.status-middle { margin: 10px 5px 0px 0px; } -.status-failing { margin-left: 14px } .right-menu { float: right; margin-right: 132px; } .help_text { color: #999; } .highlighted { background-color: #ee9; padding: 0 1px; margin: 0 1px; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; } diff --git a/readthedocs/templates/core/project_details.html b/readthedocs/templates/core/project_details.html index 021b5a6d8d6..bbb1a3abde7 100644 --- a/readthedocs/templates/core/project_details.html +++ b/readthedocs/templates/core/project_details.html @@ -33,6 +33,16 @@

      {% trans "Versions" %}

      {% if request.user in project.users.all %} {{ version.get_privacy_level_display }} {% endif %} + {% if request.user|is_admin:project %} + + {% is_latest_built_success version as is_success %} + {% if is_success %} + {% trans "passing" %} + {% else %} + {% trans "failing" %} + {% endif %} + + {% endif %} {% else %} @@ -42,16 +52,6 @@

      {% trans "Versions" %}

      {% if request.user|is_admin:project %}
      • {% trans "Edit" %}
      • -
      • - - {% is_latest_built_success version as is_success %} - {% if is_success %} - {% trans "passing" %} - {% else %} - {% trans "failing" %} - {% endif %} - -
      {% endif %}