kopia lustrzana https://github.com/wagtail/wagtail
* Fixes RoutablePage throws a TypeError (#2584) FIX: RoutablePage throws a TypeError if index route is not set * Reorder imports to prevent isort failpull/2416/merge
rodzic
e4ae108daa
commit
0467e47951
|
@ -93,7 +93,13 @@ class RoutablePageMixin(object):
|
||||||
|
|
||||||
return super(RoutablePageMixin, self).route(request, path_components)
|
return super(RoutablePageMixin, self).route(request, path_components)
|
||||||
|
|
||||||
def serve(self, request, view, args, kwargs):
|
def serve(self, request, view=None, args=None, kwargs=None):
|
||||||
|
if args is None:
|
||||||
|
args = []
|
||||||
|
if kwargs is None:
|
||||||
|
kwargs = {}
|
||||||
|
if view is None:
|
||||||
|
return super(RoutablePageMixin, self).serve(request, *args, **kwargs)
|
||||||
return view(request, *args, **kwargs)
|
return view(request, *args, **kwargs)
|
||||||
|
|
||||||
def serve_preview(self, request, mode_name):
|
def serve_preview(self, request, mode_name):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.test import RequestFactory, TestCase
|
||||||
|
|
||||||
from wagtail.contrib.wagtailroutablepage.templatetags.wagtailroutablepage_tags import \
|
from wagtail.contrib.wagtailroutablepage.templatetags.wagtailroutablepage_tags import \
|
||||||
routablepageurl
|
routablepageurl
|
||||||
from wagtail.tests.routablepage.models import RoutablePageTest
|
from wagtail.tests.routablepage.models import RoutablePageTest, RoutablePageWithoutIndexRouteTest
|
||||||
from wagtail.wagtailcore.models import Page, Site
|
from wagtail.wagtailcore.models import Page, Site
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,6 +93,16 @@ class TestRoutablePage(TestCase):
|
||||||
|
|
||||||
self.assertContains(response, "MAIN VIEW")
|
self.assertContains(response, "MAIN VIEW")
|
||||||
|
|
||||||
|
def test_get_routable_page_without_index_route(self):
|
||||||
|
page = self.home_page.add_child(
|
||||||
|
instance=RoutablePageWithoutIndexRouteTest(
|
||||||
|
title="Routable Page without index",
|
||||||
|
live=True
|
||||||
|
)
|
||||||
|
)
|
||||||
|
response = self.client.get(page.url)
|
||||||
|
self.assertContains(response, "DEFAULT PAGE TEMPLATE")
|
||||||
|
|
||||||
def test_get_archive_by_year_view(self):
|
def test_get_archive_by_year_view(self):
|
||||||
response = self.client.get(self.routable_page.url + 'archive/year/2014/')
|
response = self.client.get(self.routable_page.url + 'archive/year/2014/')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.6 on 2016-05-10 10:31
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import wagtail.contrib.wagtailroutablepage.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wagtailcore', '0028_merge'),
|
||||||
|
('routablepagetests', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='RoutablePageWithoutIndexRouteTest',
|
||||||
|
fields=[
|
||||||
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin, 'wagtailcore.page'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -32,3 +32,7 @@ class RoutablePageTest(RoutablePage):
|
||||||
@route(r'^override-name-test/$', name='name_overridden')
|
@route(r'^override-name-test/$', name='name_overridden')
|
||||||
def override_name_test(self, request):
|
def override_name_test(self, request):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RoutablePageWithoutIndexRouteTest(RoutablePage):
|
||||||
|
pass
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
DEFAULT PAGE TEMPLATE
|
Ładowanie…
Reference in New Issue