[PATCH v2 1/3] urls: Move 'help/about' to 'about'

Daniel Axtens dja at axtens.net
Mon Feb 13 07:25:14 AEDT 2017


Hi Stephen,

> 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.

Looks good to me. Hopefully increases the discoverability of the
pwclient stuff - I always struggled to find it!

> Permanent redirects are included to prevent dead links.

Tim Berners-Lee thanks you! More importantly:

Reviewed-by: Daniel Axtens <dja at axtens.net>

Regards,
Daniel

>
> Signed-off-by: Stephen Finucane <stephen at that.guru>
> ---
>  patchwork/templates/patchwork/about.html         | 14 +++++++++
>  patchwork/templates/patchwork/help/about.html    | 14 ---------
>  patchwork/templates/patchwork/help/index.html    |  2 --
>  patchwork/templates/patchwork/help/pwclient.html | 24 --------------
>  patchwork/templates/patchwork/project.html       | 19 ++++++++---
>  patchwork/tests/test_about.py                    | 32 +++++++++++++++++++
>  patchwork/tests/test_xmlrpc.py                   |  3 +-
>  patchwork/urls.py                                | 12 +++++--
>  patchwork/views/about.py                         | 36 +++++++++++++++++++++
>  patchwork/views/help.py                          | 40 ------------------------
>  patchwork/views/xmlrpc.py                        |  3 +-
>  templates/base.html                              |  2 +-
>  12 files changed, 108 insertions(+), 93 deletions(-)
>  create mode 100644 patchwork/templates/patchwork/about.html
>  delete mode 100644 patchwork/templates/patchwork/help/about.html
>  delete mode 100644 patchwork/templates/patchwork/help/index.html
>  delete mode 100644 patchwork/templates/patchwork/help/pwclient.html
>  create mode 100644 patchwork/tests/test_about.py
>  create mode 100644 patchwork/views/about.py
>  delete mode 100644 patchwork/views/help.py
>
> diff --git a/patchwork/templates/patchwork/about.html b/patchwork/templates/patchwork/about.html
> new file mode 100644
> index 0000000..ed0c421
> --- /dev/null
> +++ b/patchwork/templates/patchwork/about.html
> @@ -0,0 +1,14 @@
> +{% extends "base.html" %}
> +
> +{% block title %}About{% endblock %}
> +{% block heading %}About Patchwork{% endblock %}
> +
> +{% block body %}
> +<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 built on the <a href="http://djangoproject.com/">Django</a>
> +web framework.</p>
> +{% endblock %}
> diff --git a/patchwork/templates/patchwork/help/about.html b/patchwork/templates/patchwork/help/about.html
> deleted file mode 100644
> index ed0c421..0000000
> --- a/patchwork/templates/patchwork/help/about.html
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -{% extends "base.html" %}
> -
> -{% block title %}About{% endblock %}
> -{% block heading %}About Patchwork{% endblock %}
> -
> -{% block body %}
> -<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 built on the <a href="http://djangoproject.com/">Django</a>
> -web framework.</p>
> -{% endblock %}
> diff --git a/patchwork/templates/patchwork/help/index.html b/patchwork/templates/patchwork/help/index.html
> deleted file mode 100644
> index 5cb6467..0000000
> --- a/patchwork/templates/patchwork/help/index.html
> +++ /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
> index b419b42..0000000
> --- a/patchwork/templates/patchwork/help/pwclient.html
> +++ /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 %}
> diff --git a/patchwork/templates/patchwork/project.html b/patchwork/templates/patchwork/project.html
> index 6f7e37d..74b6f0f 100644
> --- a/patchwork/templates/patchwork/project.html
> +++ b/patchwork/templates/patchwork/project.html
> @@ -50,10 +50,19 @@
>  </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
> index 0000000..2175641
> --- /dev/null
> +++ b/patchwork/tests/test_about.py
> @@ -0,0 +1,32 @@
> +# Patchwork - automated patch tracking system
> +# Copyright (C) 2016 Stephen Finucane <stephen at 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)
> diff --git a/patchwork/tests/test_xmlrpc.py b/patchwork/tests/test_xmlrpc.py
> index 3b97fb1..ddaded8 100644
> --- a/patchwork/tests/test_xmlrpc.py
> +++ b/patchwork/tests/test_xmlrpc.py
> @@ -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):
> diff --git a/patchwork/urls.py b/patchwork/urls.py
> index 33e4781..ec1fd7f 100644
> --- a/patchwork/urls.py
> +++ b/patchwork/urls.py
> @@ -22,10 +22,10 @@ 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 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
> @@ -122,8 +122,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:
> @@ -140,6 +144,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:
> diff --git a/patchwork/views/about.py b/patchwork/views/about.py
> new file mode 100644
> index 0000000..86ef952
> --- /dev/null
> +++ b/patchwork/views/about.py
> @@ -0,0 +1,36 @@
> +# Patchwork - automated patch tracking system
> +# Copyright (C) 2008 Jeremy Kerr <jk at ozlabs.org>
> +# Copyright (C) 2016 Stephen Finucane <stephen at 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.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')
> +
> +
> +def redirect(request):
> +    """Redirect for legacy URLs.
> +
> +    Remove this when Patchwork 3.0 is released.
> +    """
> +    return HttpResponsePermanentRedirect(reverse('about'))
> diff --git a/patchwork/views/help.py b/patchwork/views/help.py
> deleted file mode 100644
> index 7666b0a..0000000
> --- a/patchwork/views/help.py
> +++ /dev/null
> @@ -1,40 +0,0 @@
> -# Patchwork - automated patch tracking system
> -# Copyright (C) 2008 Jeremy Kerr <jk at ozlabs.org>
> -#
> -# 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 __future__ import absolute_import
> -
> -from django.conf import settings
> -from django.http import Http404
> -from django.shortcuts import render
> -
> -
> -help_pages = {
> -    '': 'index.html',
> -    'about/': 'about.html',
> -}
> -
> -if settings.ENABLE_XMLRPC:
> -    help_pages['pwclient/'] = 'pwclient.html'
> -
> -
> -def detail(request, path):
> -    if path in help_pages:
> -        return render(request,
> -                      'patchwork/help/' + help_pages[path])
> -    raise Http404
> diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py
> index 0c3f581..1c7f0e9 100644
> --- a/patchwork/views/xmlrpc.py
> +++ b/patchwork/views/xmlrpc.py
> @@ -141,8 +141,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()
>  
> diff --git a/templates/base.html b/templates/base.html
> index 3c9fc7d..8045b51 100644
> --- a/templates/base.html
> +++ b/templates/base.html
> @@ -114,7 +114,7 @@
>    <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>
> -- 
> 2.7.4
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork


More information about the Patchwork mailing list