Skip to content

Commit bd202f9

Browse files
committed
add article tile block
1 parent ba912f5 commit bd202f9

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

Diff for: cdhweb/pages/blocks/article_index_block.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from wagtail import blocks
2+
from springkit.blocks.headings import HeadingBlock
3+
from springkit.blocks.jumplinks import JumplinkMixin
4+
from cdhweb.pages.blocks.link import InternalPageLinkBlock
5+
6+
class ArticleTileBlock(JumplinkMixin):
7+
"""
8+
CMS controlled Article Tile block
9+
"""
10+
11+
heading = HeadingBlock(required=False, help_text="Heading for this tile block")
12+
13+
description = blocks.CharBlock(
14+
help_text="Description for this tile block",
15+
label="Description",
16+
required=False,
17+
)
18+
19+
#TODO update page types
20+
landing_page = blocks.PageChooserBlock(
21+
required=True,
22+
page_type=["events.EventsLandingPage", "events.EventsLinkPageArchived", "projects.ProjectsLandingPage",
23+
"people.PeopleLandingPage", "projects.ProjectsLandingPageArchived", "people.PeopleLandingPageArchived", "blog.BlogLinkPage"],
24+
help_text=(
25+
"Select the Landing Page whose child pages you want to show as "
26+
"tiles in this block."
27+
),
28+
)
29+
30+
see_more_link = InternalPageLinkBlock(help_text="'See more' link", required=False)
31+
32+
def get_context(self, value, parent_context=None):
33+
context = super().get_context(value, parent_context=parent_context)
34+
35+
print("*******")
36+
print(value.get('landing_page').get_children().live().public().specific()[:5])
37+
# child_pages = (
38+
# value.get("article_index_page")
39+
# .get_children()
40+
# .live()
41+
# .public()
42+
# .order_by("-articlepage__article_date") # Sort by date descending
43+
# .specific()
44+
# )
45+
46+
47+
# tiles = child_pages[:max_value]
48+
49+
# context["tiles"] = tiles
50+
return context
51+
52+
class Meta:
53+
template = "cdhpages/blocks/article_tile_block.html"
54+
label = "Article Tile Block"

Diff for: cdhweb/pages/blocks/tile_block.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TileExternalLink(blocks.StructBlock):
3232

3333

3434
class TileInternalPage(blocks.StructBlock):
35-
page = blocks.PageChooserBlock(required=True)
35+
page = blocks.PageChooserBlock(required=True, page_type=["events.Event", "projects.Project", "people.Profile", "blog.BlogPost", "cdhpages.ContentPage"])
3636

3737

3838
class StandardTileBlock(JumplinkMixin):

Diff for: cdhweb/pages/models.py

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from .blocks.tile_block import StandardTileBlock
4949
from .blocks.video_block import Video
5050
from .mixin import HomePageHeroMixin, SidebarNavigationMixin, StandardHeroMixin
51+
from .blocks.article_index_block import ArticleTileBlock
5152

5253
#: common features for paragraph text
5354
PARAGRAPH_FEATURES = [
@@ -87,6 +88,7 @@
8788
("newsletter", NewsletterBlock()),
8889
("heading", JumplinkableH2Block()),
8990
("tile_block", StandardTileBlock()),
91+
("article_tile_block", ArticleTileBlock())
9092
]
9193

9294

Diff for: templates/cdhpages/blocks/article_tile_block.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h2>Article Tile BLock</h2>

0 commit comments

Comments
 (0)