Skip to content

Commit

Permalink
Restricting Page Hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
KalobTaulien committed Mar 25, 2019
1 parent ec1b75b commit c4cf47b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions blog/models.py
Expand Up @@ -154,6 +154,8 @@ class BlogListingPage(RoutablePageMixin, Page):
"""Listing page lists all the Blog Detail Pages."""

template = "blog/blog_listing_page.html"
max_count = 1
subpage_types = ['blog.VideoBlogPage', 'blog.ArticleBlogPage']

custom_title = models.CharField(
max_length=100,
Expand Down Expand Up @@ -215,6 +217,9 @@ def get_sitemap_urls(self, request):
class BlogDetailPage(Page):
"""Parental blog detail page."""

subpage_types = []
parent_page_types = ['blog.BlogListingPage']

custom_title = models.CharField(
max_length=100,
blank=False,
Expand Down
3 changes: 3 additions & 0 deletions contact/models.py
Expand Up @@ -24,6 +24,9 @@ class FormField(AbstractFormField):
class ContactPage(WagtailCaptchaEmailForm):

template = "contact/contact_page.html"
subpage_types = []
parent_page_types = ['home.HomePage']

# This is the default path.
# If ignored, Wagtail adds _landing.html to your template name
landing_page_template = "contact/contact_page_landing.html"
Expand Down
6 changes: 5 additions & 1 deletion flex/models.py
Expand Up @@ -12,7 +12,11 @@ class FlexPage(Page):
"""Flexible page class."""

template = "flex/flex_page.html"

subpage_types = ['flex.FlexPage', 'contact.ContactPage']
parent_page_types = [
'flex.FlexPage',
'home.HomePage',
]
content = StreamField(
[
("title_and_text", blocks.TitleAndTextBlock()),
Expand Down
9 changes: 8 additions & 1 deletion home/models.py
Expand Up @@ -43,7 +43,14 @@ class HomePage(RoutablePageMixin, Page):
"""Home page model."""

template = "home/home_page.html"
max_count = 1
subpage_types = [
'blog.BlogListingPage',
'contact.ContactPage',
'flex.FlexPage',
]
parent_page_type = [
'wagtailcore.Page'
]

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

1 comment on commit c4cf47b

@KalobTaulien
Copy link
Member Author

@KalobTaulien KalobTaulien commented on c4cf47b Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.