diff --git a/wagtail/wagtailadmin/tests/test_pages_views.py b/wagtail/wagtailadmin/tests/test_pages_views.py index 65a614538d..aa73e907dd 100644 --- a/wagtail/wagtailadmin/tests/test_pages_views.py +++ b/wagtail/wagtailadmin/tests/test_pages_views.py @@ -245,7 +245,6 @@ class TestPageCreation(TestCase, WagtailTestUtils): response = self.client.get(reverse('wagtailadmin_pages_create', args=('tests', 'simplepage', 100000))) self.assertEqual(response.status_code, 404) - @unittest.expectedFailure # FIXME: Crashes! def test_create_nonpagetype(self): response = self.client.get(reverse('wagtailadmin_pages_create', args=('wagtailimages', 'image', self.root_page.id))) self.assertEqual(response.status_code, 404) diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py index 0d738d0c2b..f6490a2244 100644 --- a/wagtail/wagtailadmin/views/pages.py +++ b/wagtail/wagtailadmin/views/pages.py @@ -115,12 +115,17 @@ def create(request, content_type_app_name, content_type_model_name, parent_page_ except ContentType.DoesNotExist: raise Http404 + # Get class + page_class = content_type.model_class() + + # Make sure the class is a descendant of Page + if not issubclass(page_class, Page): + raise Http404 + # page must be in the list of allowed subpage types for this parent ID if content_type not in parent_page.clean_subpage_types(): raise PermissionDenied - page_class = content_type.model_class() - page = page_class(owner=request.user) edit_handler_class = get_page_edit_handler(page_class) form_class = edit_handler_class.get_form_class(page_class)