Skip to content

Commit

Permalink
Remove references to removed fields
Browse files Browse the repository at this point in the history
The teaching authority fields have been removed from countries so we can
remove the references to them in various other places.
  • Loading branch information
thomasleese committed Sep 7, 2023
1 parent 83855cf commit 45a14fd
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 428 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 @@ -20,16 +20,6 @@ def edit
requires_preliminary_check: country.requires_preliminary_check,
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 @@ -73,12 +63,6 @@ def country_params
:requires_preliminary_check,
: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 @@ -16,12 +16,6 @@ class SupportInterface::CountryForm
attribute :requires_preliminary_check, :boolean
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 @@ -58,12 +52,6 @@ def assign_country_attributes
requires_preliminary_check:,
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.

6 changes: 0 additions & 6 deletions app/models/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# index_countries_on_code (code) UNIQUE
#
class Country < ApplicationRecord
include TeachingAuthorityContactable

has_many :regions

LOCATION_AUTOCOMPLETE_CANONICAL_LIST =
Expand All @@ -41,8 +39,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,6 +53,11 @@ 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 }

scope :requires_preliminary_check,
Expand All @@ -67,4 +70,27 @@ class Region < ApplicationRecord
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.

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 @@ -35,7 +35,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 @@ -38,16 +38,6 @@
<p class="govuk-body"><%= govuk_boolean_tag(@country.requires_preliminary_check) %></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 @@ -78,11 +68,5 @@
<%= f.hidden_field :requires_preliminary_check, value: @form.requires_preliminary_check %>
<%= 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 %>
11 changes: 10 additions & 1 deletion app/views/support_interface/regions/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@

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

<%= f.govuk_fieldset legend: { text: "Teaching authority details" } do %>
<%= f.govuk_text_field :teaching_authority_name, label: { text: "Name" } %>
<%= f.govuk_text_area :teaching_authority_address, label: { text: "Address" } %>
<%= f.govuk_text_area :teaching_authority_emails_string, label: { text: "Email" }, hint: { text: "One email per line (if more than one)" } %>
<%= f.govuk_text_area :teaching_authority_websites_string, label: { text: "Websites" }, hint: { text: "One website per line (if more than one)" } %>
<%= f.govuk_text_field :teaching_authority_certificate, label: { text: "Name given to describe the Letter of Professional standing" } %>
<%= f.govuk_text_field :teaching_authority_online_checker_url, label: { text: "Online checker website" } %>
<%= f.govuk_text_area :teaching_authority_other, label: { text: "Teaching authority other" } %>
<% end %>

<%= f.govuk_radio_buttons_fieldset(:teaching_authority_requires_submission_email, legend: { size: 'm', text: 'Automatically notify the teaching authority (via email) every time a QTS application is submitted?' }) do %>
<%= f.govuk_radio_button :teaching_authority_requires_submission_email, 'yes', label: { text: 'Yes' }, link_errors: true %>
Expand Down
6 changes: 0 additions & 6 deletions spec/factories/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,5 @@
create(:region, :national, country:)
end
end

trait :with_teaching_authority do
teaching_authority_address { Faker::Address.street_address }
teaching_authority_emails { [Faker::Internet.email] }
teaching_authority_websites { [Faker::Internet.url] }
end
end
end
6 changes: 0 additions & 6 deletions spec/factories/regions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@
status_check { :none }
end

trait :with_teaching_authority do
teaching_authority_address { Faker::Address.street_address }
teaching_authority_emails { [Faker::Internet.email] }
teaching_authority_websites { [Faker::Internet.url] }
end

trait :in_country do
transient { country_code { "" } }
country { Country.find_or_create_by(code: country_code) }
Expand Down
Loading

0 comments on commit 45a14fd

Please sign in to comment.