Skip to content

Commit

Permalink
Refactor rendering teaching qualification information
Browse files Browse the repository at this point in the history
This aliases the column to make it clearer what this column should
contain and then adds a shared partial view that can be used to render
the information (combining both the information from the region and the
country).
  • Loading branch information
thomasleese committed May 28, 2024
1 parent d70dacd commit 0ac5550
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 20 deletions.
3 changes: 3 additions & 0 deletions app/models/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ class Country < ApplicationRecord
YAML.load(File.read("lib/countries-in-european-economic-area.yaml"))

validates :code, inclusion: { in: CODES }

alias_attribute :teaching_qualification_information,
:qualifications_information
end
3 changes: 3 additions & 0 deletions app/models/region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class Region < ApplicationRecord
}
validates :teaching_authority_online_checker_url, url: { allow_blank: true }

alias_attribute :teaching_qualification_information,
:qualifications_information

def checks_available?
!sanction_check_none? && !status_check_none?
end
Expand Down
7 changes: 7 additions & 0 deletions app/views/shared/_teaching_qualification_information.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% if region.teaching_qualification_information.present? %>
<%= raw GovukMarkdown.render(region.teaching_qualification_information) %>
<% end %>

<% if region.country.teaching_qualification_information.present? %>
<%= raw GovukMarkdown.render(region.country.teaching_qualification_information) %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,4 @@
</p>
<% end %>

<% if region.qualifications_information.present? %>
<%= raw GovukMarkdown.render(region.qualifications_information) %>
<% end %>

<% if region.country.qualifications_information.present? %>
<%= raw GovukMarkdown.render(region.country.qualifications_information) %>
<% end %>
<%= render "shared/teaching_qualification_information", region: %>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= f.govuk_fieldset legend: { text: "Proof of qualifications", size: "s" } do %>
<p class="govuk-body">Example: ‘We cannot accept the National Certificate in Education (NCE) or the Teachers Certificate Grade II from Nigeria, as these do not meet the required level.’</p>

<%= f.govuk_text_area :qualifications_information, label: { text: "Qualifications" }, rows: 5 %>
<%= f.govuk_text_area :qualifications_information, label: { text: "For the teaching qualification" }, rows: 5 %>
<% end %>

<%= f.govuk_fieldset legend: { text: "Proof that you’re recognised as a teacher", size: "s" } do %>
Expand Down
12 changes: 1 addition & 11 deletions app/views/teacher_interface/qualifications/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,7 @@
<p class="govuk-body">Add any additional qualifications you have that relate to your teaching career. These must be of a <%= govuk_link_to "UK ‘level 6’ equivalent or above", "https://www.gov.uk/what-different-qualification-levels-mean/list-of-qualification-levels" %>.</p>
<% end %>

<% if @application_form.region.qualifications_information.present? || @application_form.region.country.qualifications_information.present? %>
<section id="app-qualifications-information">
<% if @application_form.region.qualifications_information.present? %>
<%= raw GovukMarkdown.render(@application_form.region.qualifications_information) %>
<% end %>

<% if @application_form.region.country.qualifications_information.present? %>
<%= raw GovukMarkdown.render(@application_form.region.country.qualifications_information) %>
<% end %>
</section>
<% end %>
<%= render "shared/teaching_qualification_information", region: @application_form.region %>

<%= f.govuk_fieldset legend: { text: t(qualification.locale_key, scope: %i[application_form qualifications form title]) } do %>
<%= f.govuk_text_field :title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module TeacherInterface
class QualificationForm < SitePrism::Page
element :heading, "h1"
element :body, ".govuk-body-l"
element :qualifications_information, "#app-qualifications-information"

section :form, "form" do
element :title_field,
Expand Down

0 comments on commit 0ac5550

Please sign in to comment.