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

Move fatality notices from government frontend #4640

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

KludgeKML
Copy link
Contributor

@KludgeKML KludgeKML commented Feb 12, 2025

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What

We want to handle the rendering of fatality_notice documents from government-frontend to frontend.

Why

https://trello.com/c/2QCsgFab/492-move-fatality-notices-from-government-frontend-to-frontend

How

By moving the routes and necessary code to get the pages rendering in Frontend.

Page Examples

https://[HEROKU-APP-ID].herokuapp.com/government/fatalities/squadron-leader-patrick-marshall
https://[HEROKU-APP-ID].herokuapp.com/government/fatalities/lieutenant-philip-d-green-rn

Screenshots?

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 12, 2025 14:08 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 12, 2025 14:10 Inactive
@KludgeKML KludgeKML force-pushed the move-fatality-notices-from-government-frontend branch from 7d78f9a to 1391d9a Compare February 12, 2025 14:12
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 12, 2025 14:13 Inactive
@KludgeKML KludgeKML marked this pull request as draft February 12, 2025 14:14
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 12, 2025 17:04 Inactive
@KludgeKML KludgeKML force-pushed the move-fatality-notices-from-government-frontend branch from 4c38d5f to 98c043b Compare February 13, 2025 10:18
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 10:18 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 10:35 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 11:30 Inactive
@KludgeKML KludgeKML force-pushed the move-fatality-notices-from-government-frontend branch from bdb431b to cb37db2 Compare February 13, 2025 11:40
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 11:41 Inactive
@KludgeKML KludgeKML force-pushed the move-fatality-notices-from-government-frontend branch from cb37db2 to c9b6726 Compare February 13, 2025 11:41
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 11:41 Inactive
@KludgeKML KludgeKML force-pushed the move-fatality-notices-from-government-frontend branch from c9b6726 to 18a9576 Compare February 13, 2025 11:51
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 11:51 Inactive
@KludgeKML KludgeKML force-pushed the move-fatality-notices-from-government-frontend branch from 18a9576 to bf89a36 Compare February 13, 2025 11:55
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 11:56 Inactive
@KludgeKML KludgeKML force-pushed the move-fatality-notices-from-government-frontend branch from bf89a36 to 909f4b1 Compare February 13, 2025 11:58
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 11:58 Inactive
- Ran rake "consolidation:copy_translation[fatality_notice,formats.fatality_notice]"
- Note that none_added isn't actually used by fatality_notice, it's used by the related
  field_of_operation pages, but not clear if it should be moved, since it fits with
  fatality notices.

Audit trail:
https://github.com/alphagov/government-frontend/tree/72aeb637c575c3f646096d8183a02356b9e0a3ef/config/locales
- Ran rake "consolidation:copy_translation[content_item.schema_name.fatality_notice,formats.fatality_notice]"
- needed for withdrawal notices.

Audit trail:
https://github.com/alphagov/government-frontend/tree/8799336fd3c96dac7c7e53cce3cd8a522beb17da/config/locales
- as with other models, we don't want to include the messy Linkable
  concern, so inline the links_group methods (we can also simplify
  them because we know world_locations won't be included). Remove
  other presenter methods, retain field_of_operation which is
  clearly a model method.

Audit trail:
https://github.com/alphagov/government-frontend/blob/8799336fd3c96dac7c7e53cce3cd8a522beb17da/app/presenters/fatality_notice_presenter.rb
https://github.com/alphagov/government-frontend/blob/8799336fd3c96dac7c7e53cce3cd8a522beb17da/app/presenters/content_item/linkable.rb
@KludgeKML KludgeKML force-pushed the move-fatality-notices-from-government-frontend branch from 909f4b1 to c809a60 Compare February 13, 2025 12:07
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 12:07 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4640 February 13, 2025 12:12 Inactive
- image asset included needed by view.
- The only truly model method needed is the field of operations, once
  that's included from the presenter the rest of the methods could be
  done away with - the image was hardcoded, so could just be moved
  into the view, page_title has been replaced with the withdrawn_title
  method in the title_helper, title and context could be handled in the
  page with the heading component, and the important metadata was only
  ever the field of operation, so we just inline that.

Audit Trail:
- https://github.com/alphagov/government-frontend/blob/72aeb637c575c3f646096d8183a02356b9e0a3ef/app/assets/images/ministry-of-defence-crest.png
- https://github.com/alphagov/government-frontend/blob/72aeb637c575c3f646096d8183a02356b9e0a3ef/app/presenters/fatality_notice_presenter.rb
- https://github.com/alphagov/government-frontend/blob/72aeb637c575c3f646096d8183a02356b9e0a3ef/app/views/content_items/fatality_notice.html.erb
@@ -0,0 +1,5 @@
module TitleHelper
def withdrawable_title(content_item)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean we no longer need this method in the content item presenter?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 I think this is duplicating the presenter method, and it'd be better for a presenter object to be created.

I'd question this being a helper method rather than a presenter method anyway as it needs to know about the "state" and structure of the content item.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed we don't need to duplicate it. I will note that I don't think "page_title" is a great method name for something that has one job (decorating a withdrawn title). I'm going to drop this commit and use the existing method, but perhaps we could revisit the name.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't mind the name as I think it describes what it is. What I would like to do is to move the "- GOV.UK" part into the presenter method so that we can consolidate it with the Application Helper method and then make the use of page_title consistent as there are a few places where "- GOV.UK" is being tacked onto the content item title.

Copy link
Contributor

@leenagupte leenagupte left a comment

Choose a reason for hiding this comment

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

This is a good start, but I feel that a few things have been missed. I think this has been rushed a bit, and that it could have done with sometime looking around at the other consolidated routes to see what patterns etc already exist.

The audit trail in the commits is great though and the system tests look pretty thorough.

Other comments and recommendations have been added inline.

end

def contributors
organisations_ordered_by_emphasis + links_group(%w[worldwide_organisations people speaker])
Copy link
Contributor

Choose a reason for hiding this comment

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

If worldwide_organisations are needed then the WorldwideOrganisations concern will need to be included.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do fatality notices have a "speaker"?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder how many content items need to access "people" in contributors. Perhaps people should be it's own model?

Do we need to start thinking about modelling Links? Not a linkable concern, but something that does the job of getting the title and base_path so we don't have to keep repeating that code?

content_item_links = content_store_hash["links"]["field_of_operation"]
if content_item_links
attributes = content_item_links.first
OpenStruct.new(title: attributes["title"], path: attributes["base_path"])
Copy link
Contributor

Choose a reason for hiding this comment

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

This is nice! I think we should use this pattern in other places too.


describe "#field_of_operation" do
it "returns the field of operation link structure" do
model_instance = described_class.new(content_item)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick. I'd probably have called this content_item rather than model_instance as it's being set to an instance of ContentItem.

@@ -0,0 +1,5 @@
module TitleHelper
def withdrawable_title(content_item)
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 I think this is duplicating the presenter method, and it'd be better for a presenter object to be created.

I'd question this being a helper method rather than a presenter method anyway as it needs to know about the "state" and structure of the content item.

<%= render "govuk_publishing_components/components/metadata", {
inverse: true,
other: {
t("formats.fatality_notice.field_of_operation") => link_to(content_item.field_of_operation.title, content_item.field_of_operation.path, class: "govuk-link govuk-link--inverse"),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could call govuk_styled_link(content_item.field_of_operation.title, path content_item.field_of_operation.title, inverse: true) rather than link_to

<% end %>
</div>
<%= render "components/published_dates", {
published: display_date(content_item.first_public_at || content_item.first_published_at),
Copy link
Contributor

Choose a reason for hiding this comment

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

You could use content_item.initial_publication_date here rather than the OR.

</div>
<%= render "components/published_dates", {
published: display_date(content_item.first_public_at || content_item.first_published_at),
last_updated: display_date(content_item.public_updated_at),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be content_item.updated as that checks if there have actually been any updates. We can't trust the presence of public_updated_at as that always exists.

end

describe "GET show" do
it "returns 200" do
Copy link
Contributor

Choose a reason for hiding this comment

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

I've asked this in the speech PR too, but it'd be nice if this also checked the template being rendered.

@@ -0,0 +1,43 @@
RSpec.describe FatalityNotice do
Copy link
Contributor

Choose a reason for hiding this comment

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

This tests should also include the shared examples "it has updates" and "it has no updates"

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.

4 participants