Skip to content

Commit

Permalink
Highlights in preview panel not updating (#12205)
Browse files Browse the repository at this point in the history
* Query model instance instead of using ORM

* Add a default sort_order to factory

* Linting
  • Loading branch information
robdivincenzo authored Apr 18, 2024
1 parent 9711358 commit 0fbae42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ def generate(seed):
if participate_page is not None:
featured_highlights = [HighlightFactory.create() for i in range(3)]
participate_page.featured_highlights = [
ParticipatePage2FeaturedHighlightsFactory.build(highlight=featured_highlights[i]) for i in range(3)
ParticipatePage2FeaturedHighlightsFactory.build(highlight=featured_highlights[i], sort_order=i)
for i in range(3)
]
featured_highlights2 = [HighlightFactory.create() for i in range(6)]
participate_page.featured_highlights2 = [
ParticipatePage2FeaturedHighlights2Factory.build(highlight=featured_highlights2[i]) for i in range(6)
ParticipatePage2FeaturedHighlights2Factory.build(highlight=featured_highlights2[i], sort_order=i)
for i in range(6)
]
participate_page.save()
4 changes: 2 additions & 2 deletions network-api/networkapi/wagtailpages/pagemodels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,11 @@ class ParticipatePage2(PrimaryPage):

@property
def ordered_featured_highlights(self):
return ParticipateHighlights.objects.filter(page=self).select_related("highlight").order_by("sort_order")
return self.featured_highlights.select_related("highlight").order_by("sort_order")

@property
def ordered_featured_highlights2(self):
return ParticipateHighlights2.objects.filter(page=self).select_related("highlight").order_by("sort_order")
return self.featured_highlights2.select_related("highlight").order_by("sort_order")


class Styleguide(PrimaryPage):
Expand Down

0 comments on commit 0fbae42

Please sign in to comment.