From 69274a32424e1b3a800892b9fd04f54baaa512dd Mon Sep 17 00:00:00 2001 From: saadmk11 Date: Fri, 2 Aug 2019 15:10:09 +0600 Subject: [PATCH 1/2] do not show version wipe message on build details page for external versions --- readthedocs/templates/builds/build_detail.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/templates/builds/build_detail.html b/readthedocs/templates/builds/build_detail.html index 26fd120394c..696102a310e 100644 --- a/readthedocs/templates/builds/build_detail.html +++ b/readthedocs/templates/builds/build_detail.html @@ -122,7 +122,7 @@ {% if request.user|is_admin:project %} - {% if not build.success and build.commands.count < 4 %} + {% if not build.success and build.commands.count < 4 and not build.is_external %}

{% url 'wipe_version' build.version.project.slug build.version.slug as wipe_url %} From 11dc77a75715b620b2ea55bd49514fb66b55fb78 Mon Sep 17 00:00:00 2001 From: saadmk11 Date: Wed, 7 Aug 2019 15:28:30 +0600 Subject: [PATCH 2/2] added supports_wipe property --- readthedocs/builds/models.py | 5 +++++ readthedocs/rtd_tests/tests/test_version.py | 6 ++++++ readthedocs/templates/builds/build_detail.html | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/readthedocs/builds/models.py b/readthedocs/builds/models.py index 5207dfff19f..e0c9c83e176 100644 --- a/readthedocs/builds/models.py +++ b/readthedocs/builds/models.py @@ -340,6 +340,11 @@ def identifier_friendly(self): def is_editable(self): return self.type == BRANCH + @property + def supports_wipe(self): + """Return True if version is not external.""" + return not self.type == EXTERNAL + def get_subdomain_url(self): private = self.privacy_level == PRIVATE return self.project.get_docs_url( diff --git a/readthedocs/rtd_tests/tests/test_version.py b/readthedocs/rtd_tests/tests/test_version.py index b5033c3e581..0ca9cc124da 100644 --- a/readthedocs/rtd_tests/tests/test_version.py +++ b/readthedocs/rtd_tests/tests/test_version.py @@ -66,3 +66,9 @@ def test_commit_name_for_latest_version(self): def test_commit_name_for_external_version(self): self.assertEqual(self.external_version.commit_name, self.external_version.identifier) + + def test_version_does_not_support_wipe(self): + self.assertFalse(self.external_version.supports_wipe) + + def test_version_supports_wipe(self): + self.assertTrue(self.branch_version.supports_wipe) diff --git a/readthedocs/templates/builds/build_detail.html b/readthedocs/templates/builds/build_detail.html index 696102a310e..4124600f3ed 100644 --- a/readthedocs/templates/builds/build_detail.html +++ b/readthedocs/templates/builds/build_detail.html @@ -122,7 +122,7 @@

{% if request.user|is_admin:project %} - {% if not build.success and build.commands.count < 4 and not build.is_external %} + {% if not build.success and build.commands.count < 4 and build.version.supports_wipe %}

{% url 'wipe_version' build.version.project.slug build.version.slug as wipe_url %}