]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
templates: Add API status to about page
authorStephen Finucane <stephen@that.guru>
Sat, 19 Nov 2016 18:31:33 +0000 (18:31 +0000)
committerStephen Finucane <stephen@that.guru>
Wed, 1 Mar 2017 22:11:05 +0000 (22:11 +0000)
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 <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
patchwork/templates/patchwork/about.html
patchwork/tests/test_about.py
patchwork/views/about.py

index ed0c4214b791b119f9fdbadf9509712b9c10b23e..e087f7cf35e6c58dca5e06d0f1b7cdcaf7a758f7 100644 (file)
@@ -4,11 +4,54 @@
 {% block heading %}About Patchwork{% endblock %}
 
 {% block body %}
-<h1>About Patchwork</h1>
+<div class="container">
+  <h1>About Patchwork</h1>
 
-<p>Patchwork is free software, and is available from the
-<a href="http://jk.ozlabs.org/projects/patchwork/">Patchwork website</a>.</p>
+  <p>Patchwork is free software, and is available from the <a
+     href="http://jk.ozlabs.org/projects/patchwork/">Patchwork website</a>.
+     Documentation is available on <a
+     href="http://patchwork.readthedocs.io/">Read the Docs</a>.</p>
 
-<p>Patchwork is built on the <a href="http://djangoproject.com/">Django</a>
-web framework.</p>
+  <p>Patchwork is built on the <a href="https://djangoproject.com/">Django</a>
+  web framework using <a href="https://getbootstrap.com/">Bootstrap</a>.</p>
+
+  <div class="panel panel-default">
+    <div class="panel-heading">
+      <h3 class="panel-title">Version</h3>
+    </div>
+    <ul class="list-group">
+      <li class="list-group-item">
+        <p>2.0.0-pre</p>
+      </li>
+    </ul>
+  </div>
+
+  <div class="panel panel-default">
+    <div class="panel-heading">
+      <h3 class="panel-title">API Status</h3>
+    </div>
+    <ul class="list-group">
+      <li class="list-group-item">
+        REST
+        <span class="glyphicon glyphicon-question-sign" title="The REST
+          API"></span>
+        {% if enabled_apis.rest %}
+        <span class="label label-success pull-right">enabled</span>
+        {% else %}
+        <span class="label label-warning pull-right">disabled</span>
+        {% endif %}
+      </li>
+      <li class="list-group-item">
+        XML-RPC
+        <span class="glyphicon glyphicon-question-sign" title="The XML-RPC
+          API"></span>
+        {% if enabled_apis.xmlrpc %}
+        <span class="label label-success pull-right">enabled</span>
+        {% else %}
+        <span class="label label-warning pull-right">disabled</span>
+        {% endif %}
+      </li>
+    </ul>
+  </div>
+</div>
 {% endblock %}
index 217564108e6c34dcdd57289facfe8bdb8b7653aa..24246eddd0d7df563d79e6d56bef57d0cf7d2067 100644 (file)
@@ -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'])
index 9246eaa2ac257655a0d5cae0d0b74e7226ea38c0..6d8579d64b8cf4a594823a76b10d34977db13e7e 100644 (file)
 # 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):