0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 09:33:54 +01:00

Fix routablepageurl to work with WAGTAIL_APPEND_SLASH = False (#3856)

This commit is contained in:
Venelin Stoykov 2017-10-26 16:25:36 +03:00 committed by Karl Hobley
parent 030c6b9548
commit 57969731b2
2 changed files with 11 additions and 0 deletions

View File

@ -22,4 +22,6 @@ def routablepageurl(context, page, url_name, *args, **kwargs):
request = context['request']
base_url = page.relative_url(request.site)
routed_url = page.reverse_subpage(url_name, args=args, kwargs=kwargs)
if not base_url.endswith('/'):
base_url += '/'
return base_url + routed_url

View File

@ -1,5 +1,6 @@
from __future__ import absolute_import, unicode_literals
import mock
from django.core.urlresolvers import NoReverseMatch
from django.test import RequestFactory, TestCase
@ -185,3 +186,11 @@ class TestRoutablePageTemplateTag(TestCase):
'external_view', 'joe-bloggs')
self.assertEqual(url, self.routable_page.url + 'external/joe-bloggs/')
def test_templatetag_reverse_external_view_without_append_slash(self):
with mock.patch('wagtail.wagtailcore.models.WAGTAIL_APPEND_SLASH', False):
url = routablepageurl(self.context, self.routable_page,
'external_view', 'joe-bloggs')
expected = self.routable_page.url + '/' + 'external/joe-bloggs/'
self.assertEqual(url, expected)