]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
urls: Move 'help/about' to 'about'
authorStephen Finucane <stephen@that.guru>
Sat, 19 Nov 2016 18:31:32 +0000 (18:31 +0000)
committerStephen Finucane <stephen@that.guru>
Wed, 1 Mar 2017 22:11:05 +0000 (22:11 +0000)
This is the standard URL for such pages. This involves removing the
pwclient help page, but this is migrated to the project summary page
and detailed in the documentation.

Permanent redirects are included to prevent dead links.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
patchwork/templates/patchwork/about.html [moved from patchwork/templates/patchwork/help/about.html with 100% similarity]
patchwork/templates/patchwork/help/index.html [deleted file]
patchwork/templates/patchwork/help/pwclient.html [deleted file]
patchwork/templates/patchwork/project.html
patchwork/tests/test_about.py [new file with mode: 0644]
patchwork/tests/test_xmlrpc.py
patchwork/urls.py
patchwork/views/about.py [moved from patchwork/views/help.py with 68% similarity]
patchwork/views/xmlrpc.py
templates/base.html

diff --git a/patchwork/templates/patchwork/help/index.html b/patchwork/templates/patchwork/help/index.html
deleted file mode 100644 (file)
index 5cb6467..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-{% extends "base.html" %}
-
diff --git a/patchwork/templates/patchwork/help/pwclient.html b/patchwork/templates/patchwork/help/pwclient.html
deleted file mode 100644 (file)
index b419b42..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-{% extends "base.html" %}
-
-{% block title %}pwclient: The Patchwork command-line client{% endblock %}
-{% block heading %}pwclient{% endblock %}
-
-{% block body %}
-<h1>pwclient</h1>
-
-<p><code>pwclient</code> is the command-line client for Patchwork. Currently,
-it provides access to some read-only features of Patchwork, such as downloading
-and applying patches.</p>
-
-<p>To use pwclient, you will need:</p>
-<ul>
- <li>The <a href="{% url 'pwclient' %}">pwclient</a>
-  program (11kB, python script)</li>
- <li>(optional) a <code>.pwclientrc</code> file in your home directory.</li>
-</ul>
-
-<p>You can create your own <code>.pwclientrc</code> file. Each
-<a href="{% url 'project-list' %}">Patchwork project</a>
-provides a sample linked from the 'project info' page.</p>
-
-{% endblock %}
index 6f7e37df2d4a091fb72736e55eba9f8d0a2e6ddd..74b6f0fb62055e69f6684e9549e15d62f1bd01a9 100644 (file)
 </table>
 
 {% if enable_xmlrpc %}
-<p>Sample <a href="{% url 'help' "pwclient/" %}">Patchwork
-client</a> configuration for this project: <a
-href="{% url 'pwclientrc' project.linkname %}"
->.pwclientrc</a>.</p>
-{% endif %}
+<h2>pwclient</h2>
+
+<p><code>pwclient</code> is the command-line client for Patchwork. Currently,
+it provides access to some read-only features of Patchwork, such as downloading
+and applying patches.</p>
 
+<p>To use pwclient, you will need:</p>
+<ul>
+ <li>The <a href="{% url 'pwclient' %}">pwclient</a>
+  program (11kB, python script)</li>
+ <li>(optional) A <code><a href="{% url 'pwclientrc' project.linkname %}"
+ >.pwclientrc</a></code> file for this project, which should be stored in your
+ home directory.</li>
+</ul>
+{% endif %}
 {% endblock %}
diff --git a/patchwork/tests/test_about.py b/patchwork/tests/test_about.py
new file mode 100644 (file)
index 0000000..2175641
--- /dev/null
@@ -0,0 +1,32 @@
+# Patchwork - automated patch tracking system
+# Copyright (C) 2016 Stephen Finucane <stephen@that.guru>
+#
+# This file is part of the Patchwork package.
+#
+# Patchwork is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Patchwork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Patchwork; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+from django.core.urlresolvers import reverse
+from django.test import TestCase
+
+
+class AboutViewTest(TestCase):
+
+    def test_redirects(self):
+        for view in ['help', 'help-about', 'help-pwclient']:
+            requested_url = reverse(view)
+            redirect_url = reverse('about')
+
+            response = self.client.get(requested_url)
+            self.assertRedirects(response, redirect_url, 301)
index 3b97fb19877a66612647ff21aa779fd0ab4c0fdb..ddaded84a789feffda7737de274600c21f8cb750 100644 (file)
@@ -45,8 +45,7 @@ class XMLRPCGenericTest(XMLRPCTest):
 
     def test_get_redirect(self):
         response = self.client.patch(self.url)
-        self.assertRedirects(
-            response, reverse('help', kwargs={'path': 'pwclient/'}))
+        self.assertRedirects(response, reverse('project-list'))
 
     def test_invalid_method(self):
         with self.assertRaises(xmlrpc_client.Fault):
index 68aefc2d1d279cd33ed657d6dd773df54e0c53ef..2b2f5a52db8cd40a2631bbb3230644cc5c1260bd 100644 (file)
@@ -22,11 +22,11 @@ from django.conf.urls import url, include
 from django.contrib import admin
 from django.contrib.auth import views as auth_views
 
+from patchwork.views import about as about_views
 from patchwork.views import api as api_views
 from patchwork.views import bundle as bundle_views
 from patchwork.views import comment as comment_views
 from patchwork.views import cover as cover_views
-from patchwork.views import help as help_views
 from patchwork.views import mail as mail_views
 from patchwork.views import notification as notification_views
 from patchwork.views import patch as patch_views
@@ -127,8 +127,12 @@ urlpatterns = [
     url(r'^mail/optout/$', mail_views.optout, name='mail-optout'),
     url(r'^mail/optin/$', mail_views.optin, name='mail-optin'),
 
-    # help!
-    url(r'^help/(?P<path>.*)$', help_views.detail, name='help'),
+    # about
+    url(r'^about/$', about_views.about, name='about'),
+
+    # legacy redirects
+    url(r'^help/$', about_views.redirect, name='help'),
+    url(r'^help/about/$', about_views.redirect, name='help-about'),
 ]
 
 if 'debug_toolbar' in settings.INSTALLED_APPS:
@@ -145,6 +149,8 @@ if settings.ENABLE_XMLRPC:
         url(r'^project/(?P<project_id>[^/]+)/pwclientrc/$',
             pwclient_views.pwclientrc,
             name='pwclientrc'),
+        # legacy redirect
+        url(r'^help/pwclient/$', about_views.redirect, name='help-pwclient'),
     ]
 
 if settings.ENABLE_REST_API:
similarity index 68%
rename from patchwork/views/help.py
rename to patchwork/views/about.py
index 7666b0a81fcf4e1a937fd484e6a992fb549b2f2f..9246eaa2ac257655a0d5cae0d0b74e7226ea38c0 100644 (file)
@@ -1,5 +1,6 @@
 # Patchwork - automated patch tracking system
 # Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
+# Copyright (C) 2016 Stephen Finucane <stephen@that.guru>
 #
 # This file is part of the Patchwork package.
 #
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-from __future__ import absolute_import
-
-from django.conf import settings
-from django.http import Http404
+from django.core.urlresolvers import reverse
+from django.http import HttpResponsePermanentRedirect
 from django.shortcuts import render
 
 
-help_pages = {
-    '': 'index.html',
-    'about/': 'about.html',
-}
+def about(request):
+    return render(request, 'patchwork/about.html')
 
-if settings.ENABLE_XMLRPC:
-    help_pages['pwclient/'] = 'pwclient.html'
 
+def redirect(request):
+    """Redirect for legacy URLs.
 
-def detail(request, path):
-    if path in help_pages:
-        return render(request,
-                      'patchwork/help/' + help_pages[path])
-    raise Http404
+    Remove this when Patchwork 3.0 is released.
+    """
+    return HttpResponsePermanentRedirect(reverse('about'))
index bfbdef0ffa2b731cc5e3d538ecd436f2d26b6513..66e908ee2a4f78df38435e10719a4d238c5f5eda 100644 (file)
@@ -142,8 +142,7 @@ dispatcher = PatchworkXMLRPCDispatcher()
 @csrf_exempt
 def xmlrpc(request):
     if request.method not in ['POST', 'GET']:
-        return HttpResponseRedirect(reverse('help',
-                                            kwargs={'path': 'pwclient/'}))
+        return HttpResponseRedirect(reverse('project-list'))
 
     response = HttpResponse()
 
index 3c9fc7d2c4d5ddad694c9040a16ea9c5e4ba9544..8045b51641e39d669574e72c7c8bc49a5cae20ae 100644 (file)
   <div id="footer">
    <a href="http://jk.ozlabs.org/projects/patchwork/">patchwork</a>
    patch tracking system | <a
-   href="{% url 'help' path="about/" %}">about patchwork</a>
+   href="{% url 'about' %}">about patchwork</a>
   </div>
  </body>
 </html>