Skip to content

Commit

Permalink
Merge pull request #2922 from alphagov/add-alert-status-to-travel-advice
Browse files Browse the repository at this point in the history
Reflect travel advice alert status from travel advice publisher on the advice page
  • Loading branch information
hannalaakso authored Sep 28, 2023
2 parents 7797340 + 6fef643 commit e215a4c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 22 deletions.
7 changes: 2 additions & 5 deletions app/presenters/travel_advice_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,11 @@ def alert_status
avoid_all_travel_to_whole_country
]
alert_statuses = content_item["details"]["alert_status"] || []
alert_statuses = alert_statuses.map do |alert|
alert_statuses.map do |alert|
if allowed_statuses.include?(alert)
copy = I18n.t("travel_advice.alert_status.#{alert}_html").html_safe
view_context.tag.p(copy)
I18n.t("travel_advice.alert_status.#{alert}_html", country: country_name).html_safe
end
end

alert_statuses.join("").html_safe
end

def atom_change_description
Expand Down
9 changes: 9 additions & 0 deletions app/views/content_items/travel_advice.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
<div class="govuk-grid-column-two-thirds travel-advice__header">
<%= render 'govuk_publishing_components/components/title', @content_item.title_and_context %>

<%= render "govuk_publishing_components/components/govspeak", {
} do %>
<% @content_item.alert_status.each do |text| %>
<%= render "govuk_publishing_components/components/warning_text",
text: text
%>
<% end %>
<% end %>

<aside class="part-navigation-container" role="complementary">
<%= render "govuk_publishing_components/components/contents_list", aria: { label: t("travel_advice.pages") }, contents: @content_item.part_link_elements, underline_links: true, ga4_tracking: true %>

Expand Down
10 changes: 0 additions & 10 deletions app/views/shared/_travel_advice_first_part.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<% if content_item.alert_status.present? %>
<%= render 'govuk_publishing_components/components/govspeak', {
direction: page_text_direction,
} do %>
<div class="help-notice">
<%= raw(content_item.alert_status) %>
</div>
<% end %>
<% end %>

<%= render 'govuk_publishing_components/components/metadata', content_item.metadata %>
<% if content_item.map %>
<figure class="map">
Expand Down
1 change: 0 additions & 1 deletion config/i18n-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ data:
ignore_unused:
- 'content_item.schema_name.*.{one,other,zero,few,many,two}'
- 'corporate_information_page.*'
- 'travel_advice.alert_status.*'
- 'publication.documents.other'
8 changes: 4 additions & 4 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ en:
short_ordinal: "%e %B %Y"
travel_advice:
alert_status:
avoid_all_but_essential_travel_to_parts_html: The <abbr title="Foreign, Commonwealth and Development Office">FCDO</abbr> advise against all but essential travel to parts of the country.
avoid_all_but_essential_travel_to_whole_country_html: The <abbr title="Foreign, Commonwealth and Development Office">FCDO</abbr> advise against all but essential travel to the whole country.
avoid_all_travel_to_parts_html: The <abbr title="Foreign, Commonwealth and Development Office">FCDO</abbr> advise against all travel to parts of the country.
avoid_all_travel_to_whole_country_html: The <abbr title="Foreign, Commonwealth and Development Office">FCDO</abbr> advise against all travel to the whole country.
avoid_all_but_essential_travel_to_parts_html: <abbr title="Foreign, Commonwealth and Development Office">FCDO</abbr> advises against all but essential travel to parts of %{country}.
avoid_all_but_essential_travel_to_whole_country_html: <abbr title="Foreign, Commonwealth and Development Office">FCDO</abbr> advises against all but essential travel to %{country}.
avoid_all_travel_to_parts_html: <abbr title="Foreign, Commonwealth and Development Office">FCDO</abbr> advises against all travel to parts of %{country}.
avoid_all_travel_to_whole_country_html: <abbr title="Foreign, Commonwealth and Development Office">FCDO</abbr> advises against all travel to %{country}.
context: Foreign travel advice
pages: Travel advice pages
still_current_at: Still current at
Expand Down
7 changes: 5 additions & 2 deletions test/presenters/travel_advice_presenter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,11 @@ def schema_name
test "presents alert statuses" do
example = schema_item("full-country")
example["details"]["alert_status"] = %w[avoid_all_but_essential_travel_to_parts avoid_all_travel_to_parts]
assert present_example(example).alert_status.include?("advise against all but essential travel")
assert present_example(example).alert_status.include?("advise against all travel to parts")

presented = present_example(example)

assert presented.alert_status.first.include?("advises against all but essential travel to parts of #{presented.country_name}")
assert presented.alert_status.last.include?("advises against all travel to parts of #{presented.country_name}")
end

test "metadata uses today for 'Still current at'" do
Expand Down

0 comments on commit e215a4c

Please sign in to comment.