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 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ some hard-coded routes.
|Roadmap |hardcoded|https://www.gov.uk/roadmap
|Simple smart answer |[simple_smart_answer](https://docs.publishing.service.gov.uk/content-schemas/simple_smart_answer.html)|https://www.gov.uk/sold-bought-vehicle|
| ||https://www.gov.uk/contact-the-dvla|
|Speech |[speech](https://docs.publishing.service.gov.uk/content-schemas/speech.html)|https://www.gov.uk/government/speeches/motorcycle-testing|
|Take part |[take_part](https://docs.publishing.service.gov.uk/content-schemas/take_part.html)|https://www.gov.uk/government/get-involved/take-part/improve-your-social-housing|
|Transaction start page |[transaction](https://docs.publishing.service.gov.uk/content-schemas/transaction.html)|https://www.gov.uk/register-to-vote|
| ||https://www.gov.uk/vehicle-tax|
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/speech_controller.rb
deborahchua marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class SpeechController < ContentItemsController
def show
@presenter = SpeechPresenter.new(@content_item)
end
end
21 changes: 21 additions & 0 deletions app/models/concerns/news_image.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module NewsImage
sairamya93 marked this conversation as resolved.
Show resolved Hide resolved
extend ActiveSupport::Concern

def image
content_store_hash.dig("details", "image") || default_news_image || placeholder_image
end

private

def default_news_image
organisation = content_store_hash.dig("links", "primary_publishing_organisation")
organisation[0].dig("details", "default_news_image") if organisation.present?
end

def placeholder_image
# this image has been uploaded to asset-manager
return { "url" => "https://assets.publishing.service.gov.uk/media/5e985599d3bf7f3fc943bbd8/UK_government_logo.jpg" } if content_store_hash["document_type"] == "world_news_story"

{ "url" => "https://assets.publishing.service.gov.uk/media/5e59279b86650c53b2cefbfe/placeholder.jpg" }
end
end
32 changes: 32 additions & 0 deletions app/models/concerns/political.rb
Copy link
Contributor

Choose a reason for hiding this comment

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

The commit referenced in the commit message doesn't seem to belong to a change. I'm guessing it was cherry-picked in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it was but I have now updated the commit message

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Political
sairamya93 marked this conversation as resolved.
Show resolved Hide resolved
extend ActiveSupport::Concern

included do
def historically_political?
political? && historical?
end

def publishing_government
content_store_hash.dig(
"links", "government", 0, "title"
)
end
end

private

def political?
KludgeKML marked this conversation as resolved.
Show resolved Hide resolved
content_store_hash.dig("details", "political")
end

def historical?
government_current = content_store_hash.dig(
"links", "government", 0, "details", "current"
)

# Treat no government as not historical
return false if government_current.nil?

!government_current
end
end
8 changes: 3 additions & 5 deletions app/models/concerns/updatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ def initial_publication_date
private

def any_updates?
sairamya93 marked this conversation as resolved.
Show resolved Hide resolved
if public_updated_at && initial_publication_date
Time.zone.parse(public_updated_at) != Time.zone.parse(initial_publication_date)
else
false
end
return false unless public_updated_at && initial_publication_date

Time.zone.parse(public_updated_at) != Time.zone.parse(initial_publication_date)
end

def reverse_chronological_change_history
Expand Down
31 changes: 31 additions & 0 deletions app/models/speech.rb
Original file line number Diff line number Diff line change
@@ -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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes but I have now rebased to include the concern and model tests in their corresponding commits

include Organisations
sairamya93 marked this conversation as resolved.
Show resolved Hide resolved
include Political
include Updatable

def contributors
sairamya93 marked this conversation as resolved.
Show resolved Hide resolved
(organisations + [speaker].flatten + [speaker_without_profile].flatten).compact
end

def speaker
content_store_hash.dig("links", "speaker")
end

def speaker_without_profile
content_store_hash.dig("details", "speaker_without_profile")
end

def location
content_store_hash.dig("details", "location")
end

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

def speech_type_explanation
sairamya93 marked this conversation as resolved.
Show resolved Hide resolved
explanation = content_store_hash.dig("details", "speech_type_explanation")
" (#{explanation})" if explanation
end
end
7 changes: 7 additions & 0 deletions app/presenters/speech_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class SpeechPresenter < ContentItemPresenter
def delivery_type
sairamya93 marked this conversation as resolved.
Show resolved Hide resolved
return I18n.t("formats.speech.written_on") if content_item.document_type == "authored_article"

I18n.t("formats.speech.delivered_on")
end
end
8 changes: 8 additions & 0 deletions app/views/shared/_history_notice.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% if content_item.historically_political? %>
sairamya93 marked this conversation as resolved.
Show resolved Hide resolved
<%= render "govuk_publishing_components/components/notice", {
title: sanitize(
t("shared.historically_political", government: "<span lang='en' dir='ltr'>#{content_item.publishing_government}</span>"),
attributes: %w(lang dir),
),
} %>
<% end %>
84 changes: 84 additions & 0 deletions app/views/speech/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<% content_for :title do %>
sairamya93 marked this conversation as resolved.
Show resolved Hide resolved
KludgeKML marked this conversation as resolved.
Show resolved Hide resolved
<%= content_item.title %> - GOV.UK
<% end %>

<% content_for :extra_headers do %>
<%= render "govuk_publishing_components/components/machine_readable_metadata", { content_item: content_item.to_h, schema: :news_article } %>
<meta name="description" content="<%= strip_tags(content_item.description) %>">
<% end %>

deborahchua marked this conversation as resolved.
Show resolved Hide resolved
<div class="govuk-grid-row">
KludgeKML marked this conversation as resolved.
Show resolved Hide resolved
<div class="govuk-grid-column-two-thirds">
<%= render "govuk_publishing_components/components/heading", {
text: content_item.title,
context: I18n.t("formats.#{content_item.document_type}", count: 1),
context_locale: t_locale_fallback("formats.#{content_item.document_type}", count: 1),
average_title_length: "long",
heading_level: 1,
font_size: "l",
margin_bottom: 8,
} %>
</div>
<%= render "shared/translations" %>
<div class="govuk-grid-column-two-thirds">
<%= render "govuk_publishing_components/components/lead_paragraph", text: content_item.description %>
</div>
</div>

<%= render "shared/publisher_metadata", locals: {
from: govuk_styled_links_list(content_item.contributors),
first_published: display_date(content_item.initial_publication_date),
last_updated: display_date(content_item.updated),
see_updates_link: true,
} %>
<%= render "shared/history_notice", content_item: content_item %>
<% if content_item.withdrawn? %>
<% withdrawn_time_tag = tag.time(display_date(content_item.withdrawn_at), datetime: content_item.withdrawn_at) %>

<%= render "govuk_publishing_components/components/notice", {
title: I18n.t("withdrawn_notice.title", schema_name: I18n.t("formats.#{content_item.schema_name}", count: 1, locale: :en).downcase, withdrawn_time: withdrawn_time_tag).html_safe,
description_govspeak: content_item.withdrawn_explanation&.html_safe,
time: withdrawn_time_tag,
lang: "en",
} %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="content-bottom-margin">
<div class="responsive-bottom-margin">
<%= content_tag :div, class: "important-metadata inverse-background responsive-bottom-margin" do %>
<% delivered_on = tag.time(display_date(content_item.delivered_on_date), datetime: content_item.delivered_on_date) %>
<% speech_type_explanation = content_item.speech_type_explanation %>
<%= render "govuk_publishing_components/components/metadata", {
inverse: true,
other: { I18n.t("formats.speech.location") => content_item.location , @presenter.delivery_type => "#{delivered_on}#{speech_type_explanation}" },
margin_bottom: 0,
} %>
<% end %>

<%= render "components/figure",
src: content_item.image["url"],
alt: content_item.image["alt_text"],
credit: content_item.image["credit"],
caption: content_item.image["caption"] if content_item.image %>

<%= render "govuk_publishing_components/components/govspeak", {
direction: page_text_direction,
} do %>
<%= raw(content_item.body) %>
<% end %>
</div>

<%= render "components/published_dates", {
published: display_date(content_item.initial_publication_date),
last_updated: display_date(content_item.updated),
history: content_item.history,
} %>
</div>
</div>

<%= render "shared/sidebar_navigation" %>
</div>

<%= render "shared/footer_navigation" %>
1 change: 1 addition & 0 deletions config/govuk_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ homepage: /
place: /find-regional-passport-office
simple_smart_answer: /sold-bought-vehicle
special-route: /find-local-council
speeches: /government/speeches/motorcycle-testing
take_part: /government/get-involved/take-part/improve-your-social-housing
transaction: /sign-in-universal-credit
travel_advice_index: /foreign-travel-advice
Expand Down
33 changes: 33 additions & 0 deletions config/locales/ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,13 @@ ar:
error:
find:
formats:
authored_article:
few:
many:
one: مقال مؤلَّف
other: مقالات مؤلَّفة
two:
zero:
case_study:
few:
many:
Expand Down Expand Up @@ -782,6 +789,13 @@ ar:
valid_uprn_no_match_sub_html:
website:
what_you_need_to_know:
oral_statement:
few:
many:
one: بيان شفوي للبرلمان
other: بيانات شفوية للبرلمان
two:
zero:
place:
change:
find_results:
Expand All @@ -793,6 +807,16 @@ ar:
please_answer:
start_again:
your_answers:
speech:
delivered_on: تاريخ التسليم
few:
location: الموقع
many:
one: خطاب
other: خطابات
two:
written_on: تاريخ الكتابة
zero:
start_now:
take_part:
few:
Expand All @@ -819,6 +843,13 @@ ar:
still_current_at: لا يزال ساريًا في
summary: ملخص
updated: تاريخ التحديث
written_statement:
few:
many:
one: بيان خطي للبرلمان
other: بيانات خطية للبرلمان
two:
zero:
help:
index:
about:
Expand Down Expand Up @@ -1004,6 +1035,8 @@ ar:
heading:
invalid:
title:
shared:
historically_political: تم نشره بموجب %{government}
sign_up:
website:
when_do_the_clocks_change:
Expand Down
17 changes: 17 additions & 0 deletions config/locales/az.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ az:
error:
find:
formats:
authored_article:
one: Müəlliflik edilmiş məqalə
other: Müəlliflik edilmiş məqalələr
case_study:
one: Nümunə üzrə araşdırma
other: Nümunə üzrə araşdırmalar
Expand Down Expand Up @@ -486,6 +489,9 @@ az:
valid_uprn_no_match_sub_html:
website:
what_you_need_to_know:
oral_statement:
one: Parlamentə şifahi müraciət
other: Parlamentə şifahi müraciətlər
place:
change:
find_results:
Expand All @@ -497,6 +503,12 @@ az:
please_answer:
start_again:
your_answers:
speech:
delivered_on: Çatdırılıb
location: Yer
one: Nitq
other: Nitqlər
written_on: Yazılma tarixi
start_now:
take_part:
one: İştirak edin
Expand All @@ -519,6 +531,9 @@ az:
still_current_at: Hələ də qüvvədədir
summary: İcmal
updated: Yenilənib
written_statement:
one: Parlamentə yazılı müraciət
other: Parlamentə yazılı müraciətlər
help:
index:
about:
Expand Down Expand Up @@ -704,6 +719,8 @@ az:
heading:
invalid:
title:
shared:
historically_political: Bu %{government} əsasən dərc edilmişdir
sign_up:
website:
when_do_the_clocks_change:
Expand Down
Loading
Loading