From: Stephen Finucane Date: Sat, 19 Nov 2016 18:31:33 +0000 (+0000) Subject: templates: Add API status to about page X-Git-Tag: v2.0.0-rc1~81 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0ffc8ab3583944bd7ba8690c97429b22be7e4492;p=thirdparty%2Fpatchwork.git templates: Add API status to about page This is useful given that these APIs can be disabled, and likely will be for deployments where django-rest-framework is not available. The version is currently hardcoded, but this will be resolved in a future change. Signed-off-by: Stephen Finucane Reviewed-by: Daniel Axtens --- diff --git a/patchwork/templates/patchwork/about.html b/patchwork/templates/patchwork/about.html index ed0c4214..e087f7cf 100644 --- a/patchwork/templates/patchwork/about.html +++ b/patchwork/templates/patchwork/about.html @@ -4,11 +4,54 @@ {% block heading %}About Patchwork{% endblock %} {% block body %} -

About Patchwork

+
+

About Patchwork

-

Patchwork is free software, and is available from the -Patchwork website.

+

Patchwork is free software, and is available from the Patchwork website. + Documentation is available on Read the Docs.

-

Patchwork is built on the Django -web framework.

+

Patchwork is built on the Django + web framework using Bootstrap.

+ +
+
+

Version

+
+
    +
  • +

    2.0.0-pre

    +
  • +
+
+ +
+
+

API Status

+
+
    +
  • + REST + + {% if enabled_apis.rest %} + enabled + {% else %} + disabled + {% endif %} +
  • +
  • + XML-RPC + + {% if enabled_apis.xmlrpc %} + enabled + {% else %} + disabled + {% endif %} +
  • +
+
+
{% endblock %} diff --git a/patchwork/tests/test_about.py b/patchwork/tests/test_about.py index 21756410..24246edd 100644 --- a/patchwork/tests/test_about.py +++ b/patchwork/tests/test_about.py @@ -30,3 +30,24 @@ class AboutViewTest(TestCase): response = self.client.get(requested_url) self.assertRedirects(response, redirect_url, 301) + + def test_xmlrpc(self): + with self.settings(ENABLE_XMLRPC=False): + response = self.client.get(reverse('about')) + self.assertFalse(response.context['enabled_apis']['xmlrpc']) + + with self.settings(ENABLE_XMLRPC=True): + response = self.client.get(reverse('about')) + self.assertTrue(response.context['enabled_apis']['xmlrpc']) + + def test_rest(self): + # TODO(stephenfin): There appears to be a bug in Django 1.10.x under + # Python 3.5, meaning we can't use 'override_settings' here or we cause + # the REST API tests to fail. We should investigate this. + with self.settings(ENABLE_REST_API=False): + response = self.client.get(reverse('about')) + self.assertFalse(response.context['enabled_apis']['rest']) + + with self.settings(ENABLE_REST_API=True): + response = self.client.get(reverse('about')) + self.assertTrue(response.context['enabled_apis']['rest']) diff --git a/patchwork/views/about.py b/patchwork/views/about.py index 9246eaa2..6d8579d6 100644 --- a/patchwork/views/about.py +++ b/patchwork/views/about.py @@ -18,13 +18,21 @@ # along with Patchwork; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +from django.conf import settings from django.core.urlresolvers import reverse from django.http import HttpResponsePermanentRedirect from django.shortcuts import render def about(request): - return render(request, 'patchwork/about.html') + context = { + 'enabled_apis': { + 'rest': settings.ENABLE_REST_API, + 'xmlrpc': settings.ENABLE_XMLRPC, + }, + } + + return render(request, 'patchwork/about.html', context) def redirect(request):