Skip to content

Add BlogPage.related_posts #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

bmispelon
Copy link
Collaborator

@bmispelon bmispelon commented Apr 10, 2025

Link to Ticket

Description of Changes Made

This PR adds a new RelatedBlogPage model which enables editor to select related blog pages that will replace the ones that were automatically generated before.

Acceptance criteria (from ticket)

(✅ means implemented, ❌ means not implemented)

  • ✅ Scenario: Selecting up to three related blog posts
  • ❌ Scenario: Blog posts list is filtered by division (1)
  • ✅ Scenario: No manual selection triggers automatic related posts
  • ✅ Scenario: Displaying manually selected blog posts
  • ✅ Scenario: Partial manual selection does not trigger auto-fill (2)

(1): I could not figure out how to filter the list, but I think I would know how to implement validation where the admin would get an error when saving, telling them they need to pick a page from the same division

(2) I'm not sure I understood this AC (the title and description seems to contradict each other). I took it to mean that the list of related posts should be padded to always be of length 3. So if I select only 1 related post manually, the system should fill in 2 automatic related posts (and the manually selected one should come first)

How to Test

  1. Edit a blog page in the wagtail admin
  2. In the promote tab, there's a new "related posts" field where you can select 0-3 (inclusive) blog posts
  3. Once the page is published, observe that the selected posts appear at the bottom under the "More" heading
  4. If no posts were selected manually, observe that (up to) 3 posts are listed that re fetched from the same division

Screenshots

Expand to see more

Screenshot 2025-04-10 at 10-36-57 Editing Blog page London Museum's radical digital transformation - Wagtail

MR Checklist

  • Add a description of your pull request and instructions for the reviewer to verify your work.
  • If your pull request is for a specific ticket, link to it in the description.
  • Stay on point and keep it small so the merge request can be easily reviewed.
  • Tests and linting passes.

Unit tests

  • Added
  • Not required

Documentation

Browser testing

  • I have tested in the following browsers and environments (edit the list as required)
    • Latest version of Chrome on mac
    • Latest version of Firefox on mac
    • Latest version of Safari on mac
    • Safari on last two versions of iOS
    • Chrome on last two versions of Android
  • Not required

Data protection

  • Not relevant
  • This adds new sources of PII and documents it and modifies Birdbath processors accordingly

Light and dark mode

  • I have tested the changes in both light and dark mode
  • The change is not relevant to dark and light mode

Accessibility

  • Automated WCAG 2.1 tests pass
  • HTML validation passes
  • Manual WCAG 2.1 tests completed
  • I have tested in a screen reader
  • I have tested in high-contrast mode
  • Any animations removed for prefers-reduced-motion
  • Not required

Sustainability

  • Images are optimised and lazy-loading used where appropriate
  • SVGs have been optimised
  • Performance and transfer of data considered
  • If JavaScript is needed alternatives have been considered
  • Not required

Pattern library

  • The pattern library component for this template displays correctly, and does not break parent templates
  • The styleguide is updated if relevant
  • Changes are not relevant the pattern library

@bmispelon bmispelon marked this pull request as ready for review April 10, 2025 08:43
@bmispelon bmispelon requested review from SharmaineLim and removed request for SharmaineLim April 10, 2025 08:43
@bmispelon bmispelon force-pushed the TWE-55-be-allow-editors-to-set-the-related-blog-posts branch from 854adbb to 6f01873 Compare April 10, 2025 09:20
@bmispelon bmispelon requested a review from SharmaineLim April 10, 2025 09:27
Copy link
Collaborator

@SharmaineLim SharmaineLim left a comment

Choose a reason for hiding this comment

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

Thanks, Baptiste, looking good! Just left a comment on the expected ordering– we might want to check it with Lily.

(1): I could not figure out how to filter the list, but I think I would know how to implement validation where the admin would get an error when saving, telling them they need to pick a page from the same division

Yeah, I don't think that's doable with the current parameters available to PageChooserPanel.

(2) I'm not sure I understood this AC (the title and description seems to contradict each other). I took it to mean that the list of related posts should be padded to always be of length 3. So if I select only 1 related post manually, the system should fill in 2 automatic related posts (and the manually selected one should come first)

I read that AC as well and agree. That's also usually how "related pages" work on our other projects.

@bmispelon bmispelon requested a review from SharmaineLim April 10, 2025 13:43
Copy link
Collaborator

@SharmaineLim SharmaineLim left a comment

Choose a reason for hiding this comment

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

It might be good to mention the "order by date" thing in the help text, but aside from that this LGTM!

@bmispelon bmispelon force-pushed the TWE-55-be-allow-editors-to-set-the-related-blog-posts branch from 7192018 to f049501 Compare April 11, 2025 07:42
@bmispelon
Copy link
Collaborator Author

It might be good to mention the "order by date" thing in the help text, but aside from that this LGTM!

I've added a note in the help_text and squashed all the commits together. I'll deploy to staging now 🚀

@bmispelon bmispelon merged commit 93079b6 into main Apr 14, 2025
4 checks passed
@bmispelon bmispelon deleted the TWE-55-be-allow-editors-to-set-the-related-blog-posts branch April 14, 2025 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants