Skip to content

Commit

Permalink
Merge pull request #1661 from DFE-Digital/remove-country-teaching-aut…
Browse files Browse the repository at this point in the history
…hority

Remove teaching authority fields from countries
  • Loading branch information
thomasleese authored Sep 7, 2023
2 parents 23d3f97 + 633fdc3 commit 75452b9
Show file tree
Hide file tree
Showing 26 changed files with 183 additions and 507 deletions.
16 changes: 0 additions & 16 deletions app/controllers/support_interface/countries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ def edit
region_names: country.regions.pluck(:name).join("\n"),
sanction_information: country.sanction_information,
status_information: country.status_information,
teaching_authority_address: country.teaching_authority_address,
teaching_authority_certificate:
country.teaching_authority_certificate,
teaching_authority_emails_string:
country.teaching_authority_emails_string,
teaching_authority_name: country.teaching_authority_name,
teaching_authority_online_checker_url:
country.teaching_authority_online_checker_url,
teaching_authority_websites_string:
country.teaching_authority_websites_string,
)
end

Expand Down Expand Up @@ -71,12 +61,6 @@ def country_params
:region_names,
:sanction_information,
:status_information,
:teaching_authority_address,
:teaching_authority_certificate,
:teaching_authority_emails_string,
:teaching_authority_name,
:teaching_authority_online_checker_url,
:teaching_authority_websites_string,
)
end
end
Expand Down
12 changes: 0 additions & 12 deletions app/forms/support_interface/country_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ class SupportInterface::CountryForm
attribute :region_names, :string
attribute :sanction_information, :string
attribute :status_information, :string
attribute :teaching_authority_address, :string
attribute :teaching_authority_certificate, :string
attribute :teaching_authority_emails_string, :string
attribute :teaching_authority_name, :string
attribute :teaching_authority_online_checker_url, :string
attribute :teaching_authority_websites_string, :string

validates :eligibility_enabled, inclusion: { in: [true, false] }
validates :eligibility_skip_questions, inclusion: { in: [true, false] }
Expand Down Expand Up @@ -55,12 +49,6 @@ def assign_country_attributes
qualifications_information:,
sanction_information:,
status_information:,
teaching_authority_address:,
teaching_authority_certificate:,
teaching_authority_emails_string:,
teaching_authority_name:,
teaching_authority_online_checker_url:,
teaching_authority_websites_string:,
)
end

Expand Down
20 changes: 8 additions & 12 deletions app/helpers/region_helper.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
# frozen_string_literal: true

module RegionHelper
def region_certificate_phrase(region)
certificate = region_certificate_name(region)
"#{certificate.indefinite_article} #{tag.span(certificate, lang: region.country.code)}".html_safe
end

def region_certificate_name(region)
region.teaching_authority_certificate.presence ||
region.country.teaching_authority_certificate.presence ||
"letter that proves you’re recognised as a teacher"
end

def region_certificate_phrase(region)
certificate = region_certificate_name(region)
"#{certificate.indefinite_article} #{tag.span(certificate, lang: region.country.code)}".html_safe
end

def region_teaching_authority_name(region)
region.teaching_authority_name.presence ||
region.country.teaching_authority_name.presence || "teaching authority"
region.teaching_authority_name.presence || "teaching authority"
end

def region_teaching_authority_name_phrase(region)
"the #{region_teaching_authority_name(region)}"
end

def region_teaching_authority_emails_phrase(region)
emails =
region.teaching_authority_emails +
region.country.teaching_authority_emails
emails
region
.teaching_authority_emails
.map { |email| govuk_link_to email, "mailto:#{email}" }
.to_sentence
.html_safe
Expand Down
4 changes: 2 additions & 2 deletions app/mailers/teaching_authority_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TeachingAuthorityMailer < ApplicationMailer
def application_submitted
view_mail(
GOVUK_NOTIFY_TEMPLATE_ID,
to: region.teaching_authority_emails + country.teaching_authority_emails,
to: region.teaching_authority_emails,
subject:
I18n.t(
"mailer.teaching_authority.application_submitted.subject",
Expand All @@ -25,7 +25,7 @@ def application_form
params[:application_form]
end

delegate :region, :country, to: :application_form
delegate :region, to: :application_form

def set_application_form
@application_form = application_form
Expand Down
36 changes: 0 additions & 36 deletions app/models/concerns/teaching_authority_contactable.rb

This file was deleted.

32 changes: 10 additions & 22 deletions app/models/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@
#
# Table name: countries
#
# id :bigint not null, primary key
# code :string not null
# eligibility_enabled :boolean default(TRUE), not null
# eligibility_skip_questions :boolean default(FALSE), not null
# other_information :text default(""), not null
# qualifications_information :text default(""), not null
# sanction_information :string default(""), not null
# status_information :string default(""), not null
# teaching_authority_address :text default(""), not null
# teaching_authority_certificate :text default(""), not null
# teaching_authority_emails :text default([]), not null, is an Array
# teaching_authority_name :text default(""), not null
# teaching_authority_online_checker_url :string default(""), not null
# teaching_authority_websites :text default([]), not null, is an Array
# created_at :datetime not null
# updated_at :datetime not null
# id :bigint not null, primary key
# code :string not null
# eligibility_enabled :boolean default(TRUE), not null
# eligibility_skip_questions :boolean default(FALSE), not null
# other_information :text default(""), not null
# qualifications_information :text default(""), not null
# sanction_information :string default(""), not null
# status_information :string default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_countries_on_code (code) UNIQUE
#
class Country < ApplicationRecord
include TeachingAuthorityContactable

has_many :regions

LOCATION_AUTOCOMPLETE_CANONICAL_LIST =
Expand All @@ -46,8 +38,4 @@ class Country < ApplicationRecord
CODES_ELIGIBLE_IN_FEBRUARY_2023 - %w[HK UA]

validates :code, inclusion: { in: CODES }

validates :teaching_authority_online_checker_url, url: { allow_blank: true }

alias_method :country, :itself
end
30 changes: 28 additions & 2 deletions app/models/region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
# fk_rails_... (country_id => countries.id)
#
class Region < ApplicationRecord
include TeachingAuthorityContactable

belongs_to :country
has_many :eligibility_checks

Expand All @@ -55,9 +53,37 @@ class Region < ApplicationRecord
validates :sanction_check, inclusion: { in: sanction_checks.values }
validates :status_check, inclusion: { in: status_checks.values }

validates :teaching_authority_name,
format: {
without: /\Athe.*\z/i,
message: "Teaching authority name shouldn't start with ‘the’.",
}
validates :teaching_authority_online_checker_url, url: { allow_blank: true }

def checks_available?
!sanction_check_none? && !status_check_none?
end

def teaching_authority_emails_string
teaching_authority_emails.join("\n")
end

def teaching_authority_emails_string=(string)
self.teaching_authority_emails =
string.split("\n").map(&:chomp).compact_blank
end

def teaching_authority_websites_string
teaching_authority_websites.join("\n")
end

def teaching_authority_websites_string=(string)
self.teaching_authority_websites =
string.split("\n").map(&:chomp).compact_blank
end

def teaching_authority_present?
teaching_authority_name.present? || teaching_authority_address.present? ||
teaching_authority_emails.present? || teaching_authority_websites.present?
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@
<% end %>

<%= govuk_accordion do |accordion| %>
<% if region.teaching_authority_online_checker_url.present? || region.country.teaching_authority_online_checker_url.present? %>
<% if (online_checker_url = region.teaching_authority_online_checker_url).present? %>
<% accordion.with_section(heading_text: "Online checker") do %>
<p class="govuk-body">This authority has an online checker for validating the supplied registration number:</p>

<% if (online_checker_url = region.teaching_authority_online_checker_url).present? %>
<p class="govuk-body"><%= govuk_link_to online_checker_url, online_checker_url, target: "_blank", rel: "noreferrer noopener" %></p>
<% end %>

<% if (online_checker_url = region.country.teaching_authority_online_checker_url).present? %>
<p class="govuk-body"><%= govuk_link_to online_checker_url, online_checker_url, target: "_blank", rel: "noreferrer noopener" %></p>
<% end %>
<p class="govuk-body"><%= govuk_link_to online_checker_url, online_checker_url, target: "_blank", rel: "noreferrer noopener" %></p>
<% end %>
<% end %>

Expand Down
24 changes: 20 additions & 4 deletions app/views/shared/_teaching_authority_contact_information.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
<%= render "shared/teaching_authority_contactable", contactable: region.country %>
<% if region.teaching_authority_name.present? %>
<p class="govuk-body" lang="<%= region.country.code %>"><%= region.teaching_authority_name %></p>
<% end %>

<% if region.teaching_authority_address.present? %>
<p class="govuk-body app-teaching-authority-address" lang="<%= region.country.code %>"><%= region.teaching_authority_address %></p>
<% end %>

<% if region.country.teaching_authority_present? && region.teaching_authority_present? %>
<p class="govuk-body">or</p>
<% if region.teaching_authority_emails.present? %>
<p class="govuk-body">
<% region.teaching_authority_emails.each do |email| %>
<%= govuk_link_to email, "mailto:#{email}" %><br />
<% end %>
</p>
<% end %>

<%= render "shared/teaching_authority_contactable", contactable: region %>
<% if region.teaching_authority_websites.present? %>
<p class="govuk-body">
<% region.teaching_authority_websites.each do |website| %>
<%= govuk_link_to website, website %><br />
<% end %>
</p>
<% end %>
23 changes: 0 additions & 23 deletions app/views/shared/_teaching_authority_contactable.html.erb

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion app/views/support_interface/countries/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
legend: { text: "Eligibility checker" },
hint: { text: 'Which route will applicants take through the eligibility checker?' } %>

<%= render "shared/support_interface/forms/teaching_authority_form_fields", f: %>
<%= render "shared/support_interface/forms/additional_information", f: %>

<%= f.govuk_submit "Preview", name: "preview", value: "true" do %>
Expand Down
16 changes: 0 additions & 16 deletions app/views/support_interface/countries/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@
<p class="govuk-body"><%= govuk_boolean_tag(@country.eligibility_enabled) %></p>
<% end %>

<% if @country.changes.keys.select { |k| k.starts_with?("teaching_authority_") }.any? %>
<h3 class="govuk-heading-s">Teaching authority</h3>

<%= render "shared/teaching_authority_contactable", contactable: @country %>

<p class="govuk-body"><%= @country.teaching_authority_certificate %></p>

<p class="govuk-body"><%= @country.teaching_authority_online_checker_url %></p>
<% end %>

<% if @country.sanction_information_changed? %>
<h3 class="govuk-heading-s">Sanction information</h3>
<%= raw GovukMarkdown.render(@country.sanction_information) %>
Expand Down Expand Up @@ -72,11 +62,5 @@
<%= f.hidden_field :region_names, value: @form.region_names %>
<%= f.hidden_field :sanction_information, value: @form.sanction_information %>
<%= f.hidden_field :status_information, value: @form.status_information %>
<%= f.hidden_field :teaching_authority_address, value: @form.teaching_authority_address %>
<%= f.hidden_field :teaching_authority_certificate, value: @form.teaching_authority_certificate %>
<%= f.hidden_field :teaching_authority_emails_string, value: @form.teaching_authority_emails_string %>
<%= f.hidden_field :teaching_authority_name, value: @form.teaching_authority_name %>
<%= f.hidden_field :teaching_authority_online_checker_url, value: @form.teaching_authority_online_checker_url %>
<%= f.hidden_field :teaching_authority_websites_string, value: @form.teaching_authority_websites_string %>
<%= f.govuk_submit "Save", name: "preview", value: "false" %>
<% end %>
Loading

0 comments on commit 75452b9

Please sign in to comment.