Skip to content

Commit

Permalink
Merge branch 'integration/2024-evolution' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
SharmaineLim committed Feb 10, 2025
2 parents 9165b1b + ee5b592 commit c79452d
Show file tree
Hide file tree
Showing 30 changed files with 986 additions and 240 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Build site (_site directory name is used for Jekyll compatiblity)
run: mkdocs build --config-file ./mkdocs.yml --site-dir ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3

deploy:
needs: build
Expand Down
57 changes: 57 additions & 0 deletions tbx/blog/migrations/0028_divisionmixin_and_navigationsetmixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Generated by Django 5.1.4 on 2025-01-28 09:34

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("blog", "0027_update_theme_colour_choices"),
("divisions", "0002_divisionmixin_and_navigationsetmixin"),
("navigation", "0007_divisionmixin_and_navigationsetmixin"),
]

operations = [
migrations.AddField(
model_name="blogindexpage",
name="division",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="divisions.divisionpage",
),
),
migrations.AddField(
model_name="blogindexpage",
name="override_navigation_set",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="navigation.navigationset",
),
),
migrations.AddField(
model_name="blogpage",
name="division",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="divisions.divisionpage",
),
),
migrations.AddField(
model_name="blogpage",
name="override_navigation_set",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="navigation.navigationset",
),
),
]
26 changes: 6 additions & 20 deletions tbx/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@
from bs4 import BeautifulSoup

from tbx.core.blocks import StoryBlock
from tbx.core.models import BasePage
from tbx.core.utils.fields import StreamField
from tbx.core.utils.models import (
ColourThemeMixin,
NavigationFields,
ContactMixin,
SocialFields,
)
from tbx.images.models import CustomImage
from tbx.people.models import ContactMixin
from tbx.taxonomy.models import Sector, Service


class BlogIndexPage(
ColourThemeMixin, ContactMixin, SocialFields, NavigationFields, Page
):
class BlogIndexPage(BasePage):
template = "patterns/pages/blog/blog_listing.html"

subpage_types = ["BlogPage"]
Expand Down Expand Up @@ -119,20 +117,8 @@ def get_context(self, request, *args, **kwargs):
)
return context

promote_panels = (
[
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
]
+ NavigationFields.promote_panels
+ ColourThemeMixin.promote_panels
+ ContactMixin.promote_panels
+ [
MultiFieldPanel(SocialFields.promote_panels, "Social fields"),
]
)


class BlogPage(ColourThemeMixin, ContactMixin, SocialFields, NavigationFields, Page):
class BlogPage(BasePage):
template = "patterns/pages/blog/blog_detail.html"

parent_page_types = ["BlogIndexPage"]
Expand All @@ -158,7 +144,7 @@ class BlogPage(ColourThemeMixin, ContactMixin, SocialFields, NavigationFields, P
related_services = ParentalManyToManyField(
"taxonomy.Service", related_name="blog_posts"
)
search_fields = Page.search_fields + [
search_fields = BasePage.search_fields + [
index.SearchField("body"),
]

Expand Down Expand Up @@ -243,7 +229,7 @@ def read_time(self):
def type(self):
return "BLOG POST"

content_panels = Page.content_panels + [
content_panels = BasePage.content_panels + [
InlinePanel("authors", label="Author", min_num=1),
FieldPanel("date"),
FieldPanel("body"),
Expand Down
1 change: 1 addition & 0 deletions tbx/core/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class Meta:

class FeaturedPageCardBlock(blocks.StructBlock):
heading = blocks.CharBlock(required=False)
subheading = blocks.CharBlock(required=False)
description = blocks.RichTextBlock(features=settings.NO_HEADING_RICH_TEXT_FEATURES)
image = ImageChooserBlock()
link_text = blocks.CharBlock()
Expand Down
50 changes: 50 additions & 0 deletions tbx/core/migrations/0040_divisionmixin_and_navigationsetmixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Generated by Django 5.1.4 on 2025-01-28 09:34

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("divisions", "0002_divisionmixin_and_navigationsetmixin"),
("navigation", "0007_divisionmixin_and_navigationsetmixin"),
(
"torchbox",
"0039_remove_homepage_introduction_homepage_hero_heading_and_more",
),
]

operations = [
migrations.AddField(
model_name="homepage",
name="override_navigation_set",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="navigation.navigationset",
),
),
migrations.AddField(
model_name="standardpage",
name="division",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="divisions.divisionpage",
),
),
migrations.AddField(
model_name="standardpage",
name="override_navigation_set",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="navigation.navigationset",
),
),
]
63 changes: 43 additions & 20 deletions tbx/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
)
from tbx.core.utils.models import (
ColourThemeMixin,
ContactMixin,
DivisionMixin,
NavigationFields,
NavigationSetMixin,
SocialFields,
)
from tbx.people.models import ContactMixin

from .blocks import HomePageStoryBlock, StandardPageStoryBlock

Expand Down Expand Up @@ -118,6 +120,33 @@ class Meta:
abstract = True


class BasePage(
ColourThemeMixin,
ContactMixin,
DivisionMixin,
NavigationFields,
NavigationSetMixin,
SocialFields,
Page,
):
class Meta:
abstract = True

promote_panels = (
[
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
]
+ NavigationFields.promote_panels
+ NavigationSetMixin.promote_panels
+ ColourThemeMixin.promote_panels
+ DivisionMixin.promote_panels
+ ContactMixin.promote_panels
+ [
MultiFieldPanel(SocialFields.promote_panels, "Social fields"),
]
)


class HomePagePartnerLogo(Orderable):
page = ParentalKey("torchbox.HomePage", related_name="logos")
image = models.ForeignKey(
Expand All @@ -134,7 +163,14 @@ class HomePagePartnerLogo(Orderable):


# Home Page
class HomePage(ColourThemeMixin, ContactMixin, SocialFields, NavigationFields, Page):
class HomePage(
ColourThemeMixin,
ContactMixin,
NavigationFields,
NavigationSetMixin,
SocialFields,
Page,
):
template = "patterns/pages/home/home_page.html"

parent_page_types = ["wagtailcore.Page"]
Expand All @@ -153,7 +189,7 @@ def partner_logos(self):
return [logo.image for logo in logos]
return []

content_panels = Page.content_panels + [
content_panels = BasePage.content_panels + [
MultiFieldPanel(
[
FieldPanel(
Expand Down Expand Up @@ -193,6 +229,7 @@ def partner_logos(self):
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
]
+ NavigationFields.promote_panels
+ NavigationSetMixin.promote_panels
+ ColourThemeMixin.promote_panels
+ ContactMixin.promote_panels
+ [
Expand All @@ -210,30 +247,16 @@ def get_context(self, request):


# Standard page
class StandardPage(
ColourThemeMixin, ContactMixin, SocialFields, NavigationFields, Page
):
class StandardPage(BasePage):
template = "patterns/pages/standard/standard_page.html"

body = StreamField(StandardPageStoryBlock())

content_panels = Page.content_panels + [
content_panels = BasePage.content_panels + [
FieldPanel("body"),
]

promote_panels = (
[
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
]
+ NavigationFields.promote_panels
+ ColourThemeMixin.promote_panels
+ ContactMixin.promote_panels
+ [
MultiFieldPanel(SocialFields.promote_panels, "Social fields"),
]
)

search_fields = Page.search_fields + [
search_fields = BasePage.search_fields + [
index.SearchField("body"),
]

Expand Down
8 changes: 8 additions & 0 deletions tbx/core/tests/test_division_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ def test_division_selected(self):
self.assertEqual(self.service_1.final_division, self.division_1)
self.assertEqual(service_3.final_division, self.division_2)

def test_division_self(self):
"""
For a division page,
final_division should return the page itself.
"""
self.assertEqual(self.division_1.final_division, self.division_1)
self.assertEqual(self.division_2.final_division, self.division_2)

def test_division_selected_on_ancestor(self):
"""
For a page that does not have a division selected
Expand Down
Loading

0 comments on commit c79452d

Please sign in to comment.