Skip to content
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

Generic Index Page #78

Merged
merged 47 commits into from
Feb 3, 2025
Merged

Generic Index Page #78

merged 47 commits into from
Feb 3, 2025

Conversation

kacperpONS
Copy link
Contributor

@kacperpONS kacperpONS commented Jan 16, 2025

What is the context of this PR?

Note that the Front End will differ from the current About us page that's given on the Jira card as an example of an Index page; that includes but isn't limited to the fact that the list is displayed vertically.
I've talked to Helen and John D and it appears that the design for the Index page hasn't been finalised yet, so it's likely it'll have to be revisited.

Because there's no design to refer to and the Jira card doesn't specify that, I've decided give the publisher the flexibility to add Featured pages with or without the description field.
That might cause some formatting issues when some of the block will and some won't have the description.
In order to prevent that the backend might have to be modified to get rid of this problem by making the description mandatory, making the size of the Featured items consistent.

Similarly, when child pages are displayed as the Featured items, they'll currently be displayed without the description field. Depending on the design, this might have to be changed for example by allowing the publisher to add a description for the child pages or automatically pull information from the child page summary.

How to review

Command to the unit tests just for this page:

poetry run coverage run ./manage.py test --parallel --settings=cms.settings.test cms.standard_pages.tests.test_models --keepdb
  1. For Functional testing, make sure that the new "Featured items" functionality works:

    • Check that if no "Featured items" are selected, the children pages of the Index page are displayed,
    • Check that if at least one "Featured item" is selected, then it's displayed correctly
  2. The page also uses the RelatedContentBlock in a new context - so far it was only used as one of the StreamFields available in the main content of pages. Here - it's used on it's own and as rendered as a separate onsRelatedContent component the Design System. Worth double checking that it renders correctly :)

Jira card

https://jira.ons.gov.uk/browse/CMS-180

@zerolab zerolab changed the title Generic Index Page CMS-180 Generic Index Page Jan 23, 2025
@kacperpONS
Copy link
Contributor Author

Just a note - the linters just made me format the automatically generated migrations file, might be a sign our linters are a tad too restrictive...

@kacperpONS kacperpONS marked this pull request as ready for review January 23, 2025 17:11
@kacperpONS kacperpONS requested a review from a team as a code owner January 23, 2025 17:11
cms/core/tests/factories.py Outdated Show resolved Hide resolved
cms/jinja2/templates/pages/index_page.html Outdated Show resolved Hide resolved
cms/standard_pages/models.py Outdated Show resolved Hide resolved
cms/standard_pages/models.py Outdated Show resolved Hide resolved
cms/standard_pages/models.py Outdated Show resolved Hide resolved
cms/standard_pages/models.py Outdated Show resolved Hide resolved
cms/standard_pages/models.py Outdated Show resolved Hide resolved
cms/standard_pages/tests/test_models.py Outdated Show resolved Hide resolved
cms/standard_pages/tests/test_models.py Outdated Show resolved Hide resolved
cms/standard_pages/tests/test_models.py Show resolved Hide resolved
@kacperpONS
Copy link
Contributor Author

kacperpONS commented Jan 28, 2025

Note regarding the above commit:

The check added is meant to prevent the situation where:

  1. We add and save a page that is meant to be a Feature item on the Index page (but not publish it)
  2. The page is selected as a featured_item in the RelatedContentBlock (which allows both published and not published pages to be selected)
  3. When trying to access the page details via LinkBlockStructValue.link returns None (because it checks that the page is live and ignores it if it isn’t)
  4. We get an error in the preview because we try to access the dictionary returned by .link, with
    featured_item.value.link["text"]
    but it’s None.

Possibly that’s not the most elegant solution so I’m open to suggestions.

PS It appears that doing trying to access the .link dict with getatt([featured_item.value.link], “text”, ””)
sends the empty string to the Document list UI component, and it’s still being rendered in the preview without any text in it.

PPS Shout out to @nehakerung for spotting that!

@zerolab zerolab requested a review from RealOrangeOne January 28, 2025 17:04
Copy link
Contributor

@nehakerung nehakerung left a comment

Choose a reason for hiding this comment

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

I think the altered migrations need to be addressed before this merges to main.

Copy link
Contributor

@sanjeevz3009 sanjeevz3009 left a comment

Choose a reason for hiding this comment

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

Left a few minor non-blocking comments around clean code/ refactoring. Tested everything locally, and everything seems to be working well. Looks good to me!

Great work ;)

cms/core/tests/factories.py Outdated Show resolved Hide resolved
cms/standard_pages/models.py Outdated Show resolved Hide resolved
Copy link
Contributor

@nehakerung nehakerung left a comment

Choose a reason for hiding this comment

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

LGTM - had a check through and think it looks great.

cms/standard_pages/tests/test_models.py Outdated Show resolved Hide resolved
cms/standard_pages/models.py Outdated Show resolved Hide resolved
cms/standard_pages/models.py Outdated Show resolved Hide resolved
cms/standard_pages/models.py Outdated Show resolved Hide resolved
Copy link
Contributor

@sanjeevz3009 sanjeevz3009 left a comment

Choose a reason for hiding this comment

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

LGTM!

@zerolab zerolab merged commit 3c0f160 into main Feb 3, 2025
9 checks passed
@zerolab zerolab deleted the generic-index-page-CMS-180 branch February 3, 2025 14:17
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.

5 participants