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 speech document #4573

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

Move speech document #4573

wants to merge 17 commits into from

Conversation

sairamya93
Copy link
Contributor

@sairamya93 sairamya93 commented Jan 9, 2025

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

What

To handle the rendering of Speech document type from government_frontend to frontend as part of [RFC 175]

Why

https://trello.com/c/IKDY5W9u/371-move-document-type-speech-from-government-frontend-to-frontend

How

To add a scoped route for, a controller, a model and a view. Here we split up the methods in the original file into presenter, model and its related concerns, with the minimum functionality required to get Speech document working.

Screenshots?

Frontend

Screenshot 2025-01-09 at 10 39 43
Screenshot 2025-01-09 at 10 40 22
Screenshot 2025-01-09 at 10 40 53

Government-Frontend

Screenshot 2025-01-09 at 10 44 31
Screenshot 2025-01-09 at 10 44 56
Screenshot 2025-01-09 at 10 45 59

Metadata

Screenshot 2025-01-22 at 15 02 21

@sairamya93 sairamya93 marked this pull request as draft January 9, 2025 11:25
@sairamya93 sairamya93 force-pushed the move-speech-document branch from 876a571 to 01f9f7e Compare January 9, 2025 14:50
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4573 January 9, 2025 14:51 Inactive
@sairamya93 sairamya93 force-pushed the move-speech-document branch from 01f9f7e to ce2b218 Compare January 9, 2025 16:13
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4573 January 9, 2025 16:14 Inactive
@sairamya93 sairamya93 force-pushed the move-speech-document branch from ce2b218 to c08cd5b Compare January 9, 2025 17:59
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4573 January 9, 2025 18:00 Inactive
@sairamya93 sairamya93 marked this pull request as ready for review January 10, 2025 08:50
app/models/speech.rb Outdated Show resolved Hide resolved
@sairamya93 sairamya93 force-pushed the move-speech-document branch 3 times, most recently from a50a329 to cd61575 Compare February 11, 2025 11:22
@@ -0,0 +1,4 @@
.inverse-background {
background: $govuk-brand-colour;
color: govuk-colour("white");
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder - I don't think you need to specify the color (just the background) here.

Comment on lines 69 to 73

.inverse-background {
background: $govuk-brand-colour;
color: govuk-colour("white");
}
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 since this has been moved into the helper you can remove it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, this should only be added one place.

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 looking great! 🎉 I've added some inline comments, but they're really all quite minor.

@@ -0,0 +1,31 @@
class Speech < ContentItem
include NewsImage
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 is added in a later commit? It should probably be included in the model in the commit it's added. The same goes for include Political

include Political
include Updatable

def contributors
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 method is missing a test

content_store_hash.dig("details", "delivered_on")
end

def speech_type_explanation
Copy link
Contributor

Choose a reason for hiding this comment

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

This could probably do with a test too.

@@ -0,0 +1,21 @@
RSpec.describe SpeechPresenter do
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +4 to +10
before do
{
"base_path" => "/a/base/path",
"details" => {},
"links" => {},
}
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed? What does it do?


<%= render "components/published_dates", {
published: display_date(@content_item.first_public_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 call initial_publication_date rather than first_public_at. This was the use case I found for making initial_publication_date public.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't not realise that the document_type and schema for a speech don't necessarily map: https://github.com/alphagov/publishing-api/blob/main/content_schemas/dist/formats/speech/frontend/schema.json#L34-L42

It also explains the need for the oral_statement key. 🤯

I think it's worth explaining this in the commit message.

Copy link
Contributor

Choose a reason for hiding this comment

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

content_store_has_example_item("/government/speeches/vehicle-regulations", schema: :speech)
end

describe "GET index" 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 should be "GET show"

end

describe "GET index" 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.

As well as checking for a 200 response, it might be nice to add a test to check the template being rendered. I've found that this can catch general problems with the template, i.e. a call to an attribute that doesn't exist, and syntax errors.

e.g. https://github.com/alphagov/frontend/blob/main/spec/requests/landing_page_spec.rb#L37-L41

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the reference test. I have added it

- Added Speech model that includes the related concerns for Speech[Model tests are included after adding the individual concerns]
- Modified Speech model to include the methods to retrieve the important-metadata information that were copied over from Speech Presenter in government-frontend
- Added Speech Presenter and tests to handle the delivery_type of the speech
Commit audit trail - https://github.com/alphagov/government-frontend/blob/122ae292fa540059ee165a94f8129d873c5205d5/app/presenters/speech_presenter.rb
- Modified any_updates? method with guard clause
- Added a missing test in Updatable concern

Add missing test for updatable concern
 - Add tests for speech model and its related concerns
This is added as part of rendering  important-metadata changes
Audit trail for important-metadata change: alphagov/government-frontend@b1da197

For now, inverse-background is added as a helper and imported in application.scss file
Copied over the View from government-frontend and made appropriate changes
Commit audit trail - https://github.com/alphagov/government-frontend/blob/3c8d12788047ec9ebd5c7f044f4e3f3fce0480ca/app/views/content_items/speech.html.erb

- Updated the context and context_locale to reflect the correct translations
- Modified code to render publisher_metadata
- Modified withdrawn notice code in view
- Modified code to render important-metadata
- Audit trail for important-metadata change: alphagov/government-frontend@b1da197
- Updated the component with /heading appropriate parameters instead of title component
- Removed the check for important_metadata
- Modified code to have important-metadata directly in View instead of in the presenter
 - All the locale keys for Speech are copied over from government-frontend
 - Ran the command : rake "consolidation:copy_translation[speech,formats.speech]"
Audit trail: https://github.com/alphagov/government-frontend/blob/ed44dc0a2dc1cc14174f99bdf6f1ed57f2bfc77a/config/locales
- Ran the command: consolidation:copy_translation[content_item.schema_name.written_statement,formats.written_statement]
Audit trail: https://github.com/alphagov/government-frontend/tree/ed44dc0a2dc1cc14174f99bdf6f1ed57f2bfc77a/config/locales
- To handle the pluralization for Speech in all the locales
Run the command: rake "consolidation:copy_translation[content_item.schema_name.speech,formats.speech]"

Commit audit trail: https://github.com/alphagov/government-frontend/tree/122ae292fa540059ee165a94f8129d873c5205d5/config/locales
- Ran the command: rake "consolidation:copy_translation[content_item.schema_name.oral_statement,formats.oral_statement]"
Audit trail: https://github.com/alphagov/government-frontend/tree/ed44dc0a2dc1cc14174f99bdf6f1ed57f2bfc77a/config/locales
Ran the command : govuk-docker-run rake "consolidation:copy_translation[content_item.schema_name.authored_article,formats.authored_article]"

Audit trail: https://github.com/alphagov/government-frontend/blob/8799336fd3c96dac7c7e53cce3cd8a522beb17da/config/locales/en.yml#L101-L103
Speech document type comprises of all the below:
- speech
- authored_article
- written_statement
- oral_statement
Reference document: https://github.com/alphagov/publishing-api/blob/648bddda06ad1afaeeebe2dc5f6f97da214d14ef/content_schemas/dist/formats/speech/frontend/schema.json#L34-L42
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