Skip to content

Commit

Permalink
feat: limit how news pages can be organized (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
niccofyren authored Nov 30, 2023
1 parent c846974 commit 930d53a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Example urls
- [x] Get local `docker-compose` based development setup functional and documented
- [x] Get local editor tooling functional and documented
- [ ] Get staging environment up and running using terraform (in another repo for now)
- [ ] Limit sub-page types available on `aktuelt` app
- [x] Limit sub-page types available on `aktuelt` app
- [ ] Start iterating on `aktuelt` app to get a minimal realistic and functional article setup in place (look at existing page for inspiration)
- [ ] Iterate on README and other docs to include any relevant commands and setup steps

Expand Down
5 changes: 5 additions & 0 deletions aktuelt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def get_context(self, request):


class NewsIndexPage(Page):
subpage_types = ["aktuelt.NewsPage"]

intro = RichTextField(blank=True)

content_panels = Page.content_panels + [FieldPanel("intro")]
Expand All @@ -44,6 +46,9 @@ def get_context(self, request):


class NewsPage(Page):
parent_page_types = ["aktuelt.NewsIndexPage"]
subpage_types = []

date = models.DateField("Post date")
intro = models.CharField(max_length=250)
body = RichTextField(blank=True)
Expand Down
8 changes: 8 additions & 0 deletions aktuelt/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,11 @@ def test_secret_news_page_html_is_not_readable_via_page_url(self):
newsPage = NewsPage.objects.get(title="Secret news page")
response = self.client.get(newsPage.get_url() or "/invalid-url/")
self.assertEqual(response.status_code, 404)


class AktueltNewsPageStructure(WagtailPageTestCase):
def test_news_page_can_only_be_created_under_news_index_page(self):
self.assertAllowedParentPageTypes(NewsPage, {NewsIndexPage})

def test_news_page_index_can_only_hace_news_pages_as_children(self):
self.assertAllowedSubpageTypes(NewsIndexPage, {NewsPage})

0 comments on commit 930d53a

Please sign in to comment.