From: Stephen Finucane Date: Sat, 19 Nov 2016 18:31:32 +0000 (+0000) Subject: urls: Move 'help/about' to 'about' X-Git-Tag: v2.0.0-rc1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=370e14fdd330c69da199092ac979e436879f04ed;p=thirdparty%2Fpatchwork.git urls: Move 'help/about' to 'about' 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 Reviewed-by: Daniel Axtens --- diff --git a/patchwork/templates/patchwork/help/about.html b/patchwork/templates/patchwork/about.html similarity index 100% rename from patchwork/templates/patchwork/help/about.html rename to patchwork/templates/patchwork/about.html diff --git a/patchwork/templates/patchwork/help/index.html b/patchwork/templates/patchwork/help/index.html deleted file mode 100644 index 5cb6467e..00000000 --- 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 b419b428..00000000 --- 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 %} -

pwclient

- -

pwclient is the command-line client for Patchwork. Currently, -it provides access to some read-only features of Patchwork, such as downloading -and applying patches.

- -

To use pwclient, you will need:

-
    -
  • The pwclient - program (11kB, python script)
  • -
  • (optional) a .pwclientrc file in your home directory.
  • -
- -

You can create your own .pwclientrc file. Each -Patchwork project -provides a sample linked from the 'project info' page.

- -{% endblock %} diff --git a/patchwork/templates/patchwork/project.html b/patchwork/templates/patchwork/project.html index 6f7e37df..74b6f0fb 100644 --- a/patchwork/templates/patchwork/project.html +++ b/patchwork/templates/patchwork/project.html @@ -50,10 +50,19 @@ {% if enable_xmlrpc %} -

Sample Patchwork -client configuration for this project: .pwclientrc.

-{% endif %} +

pwclient

+ +

pwclient is the command-line client for Patchwork. Currently, +it provides access to some read-only features of Patchwork, such as downloading +and applying patches.

+

To use pwclient, you will need:

+
    +
  • The pwclient + program (11kB, python script)
  • +
  • (optional) A .pwclientrc file for this project, which should be stored in your + home directory.
  • +
+{% endif %} {% endblock %} diff --git a/patchwork/tests/test_about.py b/patchwork/tests/test_about.py new file mode 100644 index 00000000..21756410 --- /dev/null +++ b/patchwork/tests/test_about.py @@ -0,0 +1,32 @@ +# Patchwork - automated patch tracking system +# Copyright (C) 2016 Stephen Finucane +# +# 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 3b97fb19..ddaded84 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 68aefc2d..2b2f5a52 100644 --- a/patchwork/urls.py +++ b/patchwork/urls.py @@ -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.*)$', 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[^/]+)/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/help.py b/patchwork/views/about.py similarity index 68% rename from patchwork/views/help.py rename to patchwork/views/about.py index 7666b0a8..9246eaa2 100644 --- a/patchwork/views/help.py +++ b/patchwork/views/about.py @@ -1,5 +1,6 @@ # Patchwork - automated patch tracking system # Copyright (C) 2008 Jeremy Kerr +# Copyright (C) 2016 Stephen Finucane # # This file is part of the Patchwork package. # @@ -17,24 +18,18 @@ # 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')) diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py index bfbdef0f..66e908ee 100644 --- a/patchwork/views/xmlrpc.py +++ b/patchwork/views/xmlrpc.py @@ -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() diff --git a/templates/base.html b/templates/base.html index 3c9fc7d2..8045b516 100644 --- a/templates/base.html +++ b/templates/base.html @@ -114,7 +114,7 @@