Skip to content

Commit

Permalink
Merge branch 'master' into CAPT-1703-prod-aks-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
vacabor authored Jul 3, 2024
2 parents 24cd1fb + 8105263 commit e2363be
Show file tree
Hide file tree
Showing 272 changed files with 4,881 additions and 1,509 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public/assets
# AKS deployment
.terraform
terraform/application/vendor
terraform/domains/infrastructure/vendor
terraform/domains/environment_domains/vendor
terraform.tfstate*
bin/terrafile
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ GEM
validate_url
webfinger (~> 1.2)
os (1.1.4)
pagy (8.4.5)
pagy (8.6.1)
parallel (1.25.1)
parallel_tests (4.7.1)
parallel
Expand Down Expand Up @@ -374,7 +374,7 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails_semantic_logger (4.14.0)
rails_semantic_logger (4.15.0)
rack
railties (>= 5.1)
semantic_logger (~> 4.13)
Expand Down
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,31 @@ get-cluster-credentials: set-azure-account-aks
bin/konduit.sh:
curl -s https://raw.githubusercontent.com/DFE-Digital/teacher-services-cloud/main/scripts/konduit.sh -o bin/konduit.sh \
&& chmod +x bin/konduit.sh

domains-infra-init: bin/terrafile domains composed-variables set-azure-account-aks
./bin/terrafile -p terraform/domains/infrastructure/vendor/modules -f terraform/domains/infrastructure/config/zones_Terrafile

terraform -chdir=terraform/domains/infrastructure init -reconfigure -upgrade \
-backend-config=resource_group_name=${RESOURCE_GROUP_NAME} \
-backend-config=storage_account_name=${STORAGE_ACCOUNT_NAME} \
-backend-config=key=domains_infrastructure.tfstate

domains-infra-plan: domains domains-infra-init ## Terraform plan for DNS infrastructure (DNS zone and front door). Usage: make domains-infra-plan
terraform -chdir=terraform/domains/infrastructure plan -var-file config/zones.tfvars.json

domains-infra-apply: domains domains-infra-init ## Terraform apply for DNS infrastructure (DNS zone and front door). Usage: make domains-infra-apply
terraform -chdir=terraform/domains/infrastructure apply -var-file config/zones.tfvars.json ${AUTO_APPROVE}

domains-init: bin/terrafile domains composed-variables set-azure-account-aks
./bin/terrafile -p terraform/domains/environment_domains/vendor/modules -f terraform/domains/environment_domains/config/${CONFIG}_Terrafile

terraform -chdir=terraform/domains/environment_domains init -upgrade -reconfigure \
-backend-config=resource_group_name=${RESOURCE_GROUP_NAME} \
-backend-config=storage_account_name=${STORAGE_ACCOUNT_NAME} \
-backend-config=key=${ENVIRONMENT}.tfstate

domains-plan: domains-init ## Terraform plan for DNS environment domains. Usage: make development domains-plan
terraform -chdir=terraform/domains/environment_domains plan -var-file config/${CONFIG}.tfvars.json

domains-apply: domains-init ## Terraform apply for DNS environment domains. Usage: make development domains-apply
terraform -chdir=terraform/domains/environment_domains apply -var-file config/${CONFIG}.tfvars.json ${AUTO_APPROVE}
4 changes: 3 additions & 1 deletion app/assets/javascripts/components/college_search.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ document.addEventListener("DOMContentLoaded", function () {
return;
}

var feOnly = form.dataset.feOnly || false;

var searchInputContainer = form.querySelector("#autocomplete-container");

if (!searchInputContainer) {
Expand Down Expand Up @@ -57,7 +59,7 @@ document.addEventListener("DOMContentLoaded", function () {
Rails.ajax({
type: "post",
url: "<%= Rails.application.routes.url_helpers.school_search_index_path %>",
data: "query=" + query,
data: "query=" + query + "&fe_only=" + feOnly.toString(),
success: handleResponse,
error: handleResponse
});
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ def start_new
delegate :slugs, :current_slug, :previous_slug, :next_slug, :next_required_slug, to: :page_sequence

def redirect_to_existing_claim_journey
new_journey = Journeys.for_routing_name(other_journey_sessions.first.journey)
# If other journey sessions is empty, then the claimant has hit the landing
# page for the journey they're already on, so we need to look at the
# existing session.
other_journey_session = other_journey_sessions.first || journey_session
new_journey = Journeys.for_routing_name(other_journey_session.journey)

# Set the params[:journey] to the new journey routing name so things like
# journey_session that rely on the journey param find the correct journey.
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/claims_form_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def information_provided_before_update
end

def personal_details_after_form_save_success
return unless journey_requires_student_loan_details?
return redirect_to_next_slug unless journey_requires_student_loan_details?

retrieve_student_loan_details
redirect_to_next_slug
Expand Down Expand Up @@ -115,7 +115,7 @@ def on_tid_route?
end

def journey_requires_student_loan_details?
student_loans_journey? || additional_payments_journey?
student_loans_journey? || additional_payments_journey? || get_a_teacher_relocation_payment_journey?
end

def student_loans_journey?
Expand All @@ -125,4 +125,8 @@ def student_loans_journey?
def additional_payments_journey?
current_journey_routing_name == "additional-payments"
end

def get_a_teacher_relocation_payment_journey?
current_journey_routing_name == "get-a-teacher-relocation-payment"
end
end
3 changes: 2 additions & 1 deletion app/controllers/school_search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ def search_schools
return
end

fe_only = ActiveModel::Type::Boolean.new.cast(params[:fe_only])
schools = ActiveModel::Type::Boolean.new.cast(params[:exclude_closed]) ? School.open : School

begin
@schools = schools.search(params[:query])
@schools = schools.search(params[:query], fe_only:)
rescue ArgumentError => e
raise unless e.message == School::SEARCH_NOT_ENOUGH_CHARACTERS_ERROR

Expand Down
23 changes: 18 additions & 5 deletions app/forms/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def i18n_errors_path(msg, args = {})
I18n.t("#{i18n_namespace}.#{base_key}", default: base_key, **args)
end

def t(key, args = {})
I18n.t(key, scope: "#{i18n_namespace}.forms.#{i18n_form_namespace}", **args)
end

def permitted_params
@permitted_params ||= params.fetch(model_name.param_key, {}).permit(*permitted_attributes)
end
Expand All @@ -49,19 +53,28 @@ def persisted?
private

def permitted_attributes
attribute_names
attributes.keys.map do |key|
field = @attributes[key]

case field.value_before_type_cast
when []
{key => []}
else
key
end
end
end

def i18n_form_namespace
self.class.name.demodulize.gsub("Form", "").underscore
end

def attributes_with_current_value
attributes.each_with_object({}) do |(attribute, _), attributes|
attributes[attribute] = permitted_params[attribute]
next unless attributes[attribute].nil?
attributes.each_with_object({}) do |(attribute, _), hash|
hash[attribute] = permitted_params[attribute]
next unless hash[attribute].nil?

attributes[attribute] = load_current_value(attribute)
hash[attribute] = load_current_value(attribute)
end
end

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Journeys
module FurtherEducationPayments
class CheckYourAnswersForm < Form
def save
true
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module Journeys
module FurtherEducationPayments
class ContractTypeForm < Form
attribute :contract_type, :string

validates :contract_type,
inclusion: {in: ->(form) { form.radio_options.map(&:id) }, message: i18n_error_message(:inclusion)}

def radio_options
[
OpenStruct.new(
id: "permanent",
name: "Permanent contract",
hint: "This includes full-time and part-time contracts"
),
OpenStruct.new(
id: "fixed-term",
name: "Fixed-term contract"
),
OpenStruct.new(
id: "variable-hours",
name: "Variable hours contract",
hint: "This includes zero hours contract and hourly paid"
)
]
end

def save
return if invalid?

journey_session.answers.assign_attributes(contract_type:)
journey_session.save!
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Journeys
module FurtherEducationPayments
class EligibleForm < Form
def save
true
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Journeys
module FurtherEducationPayments
class FurtherEducationTeachingStartYearForm < Form
attribute :further_education_teaching_start_year, :string

validates :further_education_teaching_start_year,
presence: {message: i18n_error_message(:blank)}

def radio_options
years_before = -4

array = (years_before..0).map do |delta|
academic_year = AcademicYear.current + delta
OpenStruct.new(
id: academic_year.start_year.to_s,
name: "September #{academic_year.start_year} to August #{academic_year.end_year}"
)
end

academic_year = AcademicYear.current + years_before
array << OpenStruct.new(
id: "pre-#{academic_year.start_year}",
name: "I started before September #{academic_year.start_year}"
)

array
end

def save
return false if invalid?

journey_session.answers.assign_attributes(further_education_teaching_start_year:)
journey_session.save!
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Journeys
module FurtherEducationPayments
class HalfTeachingHoursForm < Form
attribute :half_teaching_hours, :boolean

validates :half_teaching_hours,
inclusion: {
in: [true, false],
message: i18n_error_message(:inclusion)
}

def radio_options
[
OpenStruct.new(id: true, name: "Yes"),
OpenStruct.new(id: false, name: "No")
]
end

def save
return false unless valid?

journey_session.answers.assign_attributes(half_teaching_hours:)
journey_session.save!
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Journeys
module FurtherEducationPayments
class IneligibleForm < Form
def journey_eligibility_checker
@journey_eligibility_checker ||= EligibilityChecker.new(journey_session:)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def save

def results
@results ||= if journey_session.answers.school_id.present?
School.open.where(id: school_id)
School.open.fe_only.where(id: school_id)
else
School.open.search(provision_search)
School.open.fe_only.search(provision_search)
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Journeys
module FurtherEducationPayments
class SubjectsTaughtForm < Form
include ActiveModel::Validations::Callbacks

attribute :subjects_taught, default: []

before_validation :clean_subjects_taught

validates :subjects_taught,
presence: {message: i18n_error_message(:inclusion)},
inclusion: {in: ->(form) { form.checkbox_options.map(&:id) }, message: i18n_error_message(:inclusion)}

def checkbox_options
[
OpenStruct.new(id: "building-and-construction", name: "Building and construction"),
OpenStruct.new(id: "chemistry", name: "Chemistry"),
OpenStruct.new(id: "computing", name: "Computing, including digital and ICT"),
OpenStruct.new(id: "early-years", name: "Early years"),
OpenStruct.new(id: "engineering-and-manufacturing", name: "Engineering and manufacturing, including transport engineering and electronics"),
OpenStruct.new(id: "mathematics", name: "Mathematics"),
OpenStruct.new(id: "physics", name: "Physics"),
OpenStruct.new(id: "none", name: "I do not teach any of these subjects")
]
end

def save
return false unless valid?

journey_session.answers.assign_attributes(subjects_taught:)
journey_session.save!
end

private

def clean_subjects_taught
subjects_taught.reject!(&:blank?)
end
end
end
end
Loading

0 comments on commit e2363be

Please sign in to comment.