[PATCH] about: Display admin contact details

Andrew Donnellan ajd at linux.ibm.com
Wed Jul 3 13:39:53 AEST 2019


Display the list of admins on the about page. Add an ADMINS_HIDE option if
you don't want the details displayed publicly.

Closes: #282 ("Display contact details for patchwork instance admins")
Signed-off-by: Andrew Donnellan <ajd at linux.ibm.com>
---
 docs/deployment/configuration.rst        | 12 ++++++++++++
 patchwork/settings/base.py               |  8 ++++++++
 patchwork/settings/production.example.py |  3 ++-
 patchwork/templates/patchwork/about.html | 15 +++++++++++++++
 patchwork/views/about.py                 |  1 +
 5 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/docs/deployment/configuration.rst b/docs/deployment/configuration.rst
index ba9a2ebc8c97..833fd26268f5 100644
--- a/docs/deployment/configuration.rst
+++ b/docs/deployment/configuration.rst
@@ -114,3 +114,15 @@ access. This is useful if SSL protocol is terminated upstream of the server
 
 __ https://docs.djangoproject.com/en/1.8/ref/settings/
 __ http://www.django-rest-framework.org/api-guide/settings/
+
+``ADMINS``
+~~~~~~~~~~
+
+Name and email address for Patchwork instance administrators.
+
+``ADMINS_HIDE``
+~~~~~~~~~~~~~~~
+
+If True, the details in ``ADMINS`` will be hidden from the About page.
+
+.. versionadded:: 2.2
diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
index 15644b405604..c76b5af22bfc 100644
--- a/patchwork/settings/base.py
+++ b/patchwork/settings/base.py
@@ -227,3 +227,11 @@ COMPAT_REDIR = True
 # the scheme based on current access. This is useful if SSL protocol
 # is terminated upstream of the server (e.g. at the load balancer)
 FORCE_HTTPS_LINKS = False
+
+# Administrator contact details. Will be listed on the about page for users to
+# contact, unless ADMINS_HIDE is True.
+ADMINS = (
+    # Add administrator contact details in the form:
+    # ('Jeremy Kerr', 'jk at ozlabs.org'),
+)
+ADMINS_HIDE = False
diff --git a/patchwork/settings/production.example.py b/patchwork/settings/production.example.py
index f58896fc0ac7..c6aa2f2850c0 100644
--- a/patchwork/settings/production.example.py
+++ b/patchwork/settings/production.example.py
@@ -42,7 +42,8 @@ SERVER_EMAIL = DEFAULT_FROM_EMAIL
 NOTIFICATION_FROM_EMAIL = DEFAULT_FROM_EMAIL
 
 ADMINS = (
-    ('Jeremy Kerr', 'jk at ozlabs.org'),
+    # Add administrator contact details in the form:
+    # ('Jeremy Kerr', 'jk at ozlabs.org'),
 )
 
 # Database
diff --git a/patchwork/templates/patchwork/about.html b/patchwork/templates/patchwork/about.html
index f602c1351b56..b41d5fdc15ef 100644
--- a/patchwork/templates/patchwork/about.html
+++ b/patchwork/templates/patchwork/about.html
@@ -26,6 +26,21 @@
     </ul>
   </div>
 
+  {% if admins %}
+  <div class="panel panel-default">
+    <div class="panel-heading">
+      <h3 class="panel-title">Administrators</h3>
+    </div>
+    <ul class="list-group">
+      {% for admin in admins %}
+      <li class="list-group-item">
+	{{ admin.0 }} <<a href="mailto:{{ admin.1 }}">{{ admin.1 }}</a>>
+      </li>
+      {% endfor %}
+    </ul>
+  </div>
+  {% endif %}
+
   <div class="panel panel-default">
     <div class="panel-heading">
       <h3 class="panel-title">API Status</h3>
diff --git a/patchwork/views/about.py b/patchwork/views/about.py
index 0061a3195298..91c3b74ebf8f 100644
--- a/patchwork/views/about.py
+++ b/patchwork/views/about.py
@@ -16,6 +16,7 @@ def about(request):
             'rest': settings.ENABLE_REST_API,
             'xmlrpc': settings.ENABLE_XMLRPC,
         },
+        'admins': () if settings.ADMINS_HIDE else settings.ADMINS,
     }
 
     return render(request, 'patchwork/about.html', context)
-- 
2.20.1



More information about the Patchwork mailing list