Skip to content

Commit c4cf47b

Browse files
committed
Restricting Page Hierarchy
1 parent ec1b75b commit c4cf47b

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

blog/models.py

+5
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ class BlogListingPage(RoutablePageMixin, Page):
154154
"""Listing page lists all the Blog Detail Pages."""
155155

156156
template = "blog/blog_listing_page.html"
157+
max_count = 1
158+
subpage_types = ['blog.VideoBlogPage', 'blog.ArticleBlogPage']
157159

158160
custom_title = models.CharField(
159161
max_length=100,
@@ -215,6 +217,9 @@ def get_sitemap_urls(self, request):
215217
class BlogDetailPage(Page):
216218
"""Parental blog detail page."""
217219

220+
subpage_types = []
221+
parent_page_types = ['blog.BlogListingPage']
222+
218223
custom_title = models.CharField(
219224
max_length=100,
220225
blank=False,

contact/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class FormField(AbstractFormField):
2424
class ContactPage(WagtailCaptchaEmailForm):
2525

2626
template = "contact/contact_page.html"
27+
subpage_types = []
28+
parent_page_types = ['home.HomePage']
29+
2730
# This is the default path.
2831
# If ignored, Wagtail adds _landing.html to your template name
2932
landing_page_template = "contact/contact_page_landing.html"

flex/models.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ class FlexPage(Page):
1212
"""Flexible page class."""
1313

1414
template = "flex/flex_page.html"
15-
15+
subpage_types = ['flex.FlexPage', 'contact.ContactPage']
16+
parent_page_types = [
17+
'flex.FlexPage',
18+
'home.HomePage',
19+
]
1620
content = StreamField(
1721
[
1822
("title_and_text", blocks.TitleAndTextBlock()),

home/models.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ class HomePage(RoutablePageMixin, Page):
4343
"""Home page model."""
4444

4545
template = "home/home_page.html"
46-
max_count = 1
46+
subpage_types = [
47+
'blog.BlogListingPage',
48+
'contact.ContactPage',
49+
'flex.FlexPage',
50+
]
51+
parent_page_type = [
52+
'wagtailcore.Page'
53+
]
4754

4855
banner_title = models.CharField(max_length=100, blank=False, null=True)
4956
banner_subtitle = RichTextField(features=["bold", "italic"])

0 commit comments

Comments
 (0)