From 7137203480d5c4d889d05fef88ef74ee93dce0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 20 Jul 2018 10:17:11 +0200 Subject: [PATCH] misc: don't use permanent redirect for moved pages (#25390) --- combo/public/views.py | 2 +- tests/test_public.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/combo/public/views.py b/combo/public/views.py index d046ecf..266db62 100644 --- a/combo/public/views.py +++ b/combo/public/views.py @@ -363,7 +363,7 @@ def page(request): return HttpResponsePermanentRedirect(url + '/') redirect = Redirect.objects.filter(old_url=url).last() if redirect: - return HttpResponsePermanentRedirect(redirect.page.get_online_url()) + return HttpResponseRedirect(redirect.page.get_online_url()) raise Http404() return publish_page(request, page) diff --git a/tests/test_public.py b/tests/test_public.py index 2eea953..dc0f8ce 100644 --- a/tests/test_public.py +++ b/tests/test_public.py @@ -603,28 +603,28 @@ def test_redirects(app): redirect = Redirect(old_url='/whatever/', page=page3) redirect.save() - assert urlparse(app.get('/whatever/', status=301).location).path == '/second/third/' + assert urlparse(app.get('/whatever/', status=302).location).path == '/second/third/' assert urlparse(app.get('/whatever', status=301).location).path == '/whatever/' # check the most recent redirect is called redirect = Redirect(old_url='/whatever/', page=page2) redirect.save() - assert urlparse(app.get('/whatever/', status=301).location).path == '/second/' + assert urlparse(app.get('/whatever/', status=302).location).path == '/second/' # rename page page3.slug = 'third2' page3.save() assert app.get('/second/third2/', status=200) - assert urlparse(app.get('/second/third/', status=301).location).path == '/second/third2/' + assert urlparse(app.get('/second/third/', status=302).location).path == '/second/third2/' page2.slug = 'second2' page2.save() - assert urlparse(app.get('/second/third/', status=301).location).path == '/second2/third2/' - assert urlparse(app.get('/second/third2/', status=301).location).path == '/second2/third2/' - assert urlparse(app.get('/second/', status=301).location).path == '/second2/' + assert urlparse(app.get('/second/third/', status=302).location).path == '/second2/third2/' + assert urlparse(app.get('/second/third2/', status=302).location).path == '/second2/third2/' + assert urlparse(app.get('/second/', status=302).location).path == '/second2/' # change parent page3.parent = None page3.save() - assert urlparse(app.get('/second/third/', status=301).location).path == '/third2/' - assert urlparse(app.get('/second2/third2/', status=301).location).path == '/third2/' + assert urlparse(app.get('/second/third/', status=302).location).path == '/third2/' + assert urlparse(app.get('/second2/third2/', status=302).location).path == '/third2/' -- 2.18.0