Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/organisation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Organisation < ApplicationRecord
has_rich_text :description

SPECIAL_SCHOOL_TYPES = ["Community special school", "Foundation special school", "Non-maintained special school", "Academy special converter", "Academy special sponsor led", "Free schools special"].freeze
NON_FAITH_RELIGIOUS_CHARACTER_TYPES = ["", "None", "Does not apply", "null"].freeze
NON_FAITH_RELIGIOUS_CHARACTER_TYPES = ["None", "Does not apply"].freeze
OUT_OF_SCOPE_DETAILED_SCHOOL_TYPES = ["Further education", "Other independent school", "Miscellaneous", "Special post 16 institution", "Other independent special school", "Higher education institutions", "Welsh establishment"].freeze

friendly_id :slug_candidates, use: %i[slugged history]
Expand Down Expand Up @@ -53,7 +53,7 @@ class Organisation < ApplicationRecord

scope :visible_to_jobseekers, -> { schools.not_closed.not_out_of_scope.or(Organisation.trusts).registered_for_service }

scope :only_faith_schools, -> { where.not("gias_data ->> 'ReligiousCharacter (name)' IN (?)", NON_FAITH_RELIGIOUS_CHARACTER_TYPES) }
scope :only_faith_schools, -> { where.not(religious_character: NON_FAITH_RELIGIOUS_CHARACTER_TYPES) }
Comment thread
starswan marked this conversation as resolved.

# This can safely ignore the 'extra' LA mappings as it is always called with a scope which excludes LAs in the first place
scope :with_live_vacancies, lambda {
Expand Down
68 changes: 58 additions & 10 deletions app/models/school.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,64 @@ class School < Organisation
INDEPENDENT_SCHOOL_TYPE = "Independent schools".freeze
VALID_SCHOOL_TYPES = [LA_SCHOOL_TYPE, INDEPENDENT_SCHOOL_TYPE, "Special schools", "Universities", ACADEMY_TYPE, FREE_SCHOOL_TYPE, "Welsh schools", "Other types", "Colleges", "Online provider"].freeze

# This is direct from GIAS (with plurals removed via singularize)
# This is direct from GIAS
validates :school_type, inclusion: { in: VALID_SCHOOL_TYPES }

CHRISTIAN_RELIGIOUS_TYPES = ["Anglican",
"United Reformed Church",
"Christian",
"Greek Orthodox",
"Anglican/Evangelical",
"Anglican/Church of England",
"Christian/Evangelical",
"Christian/Methodist",
"Christian/non-denominational",
"Protestant/Evangelical",
"Methodist/Church of England",
"Protestant",
"Reformed Baptist",
"Christian Science",
"Church of England",
"Plymouth Brethren Christian Church",
"Church of England/Methodist/United Reform Church/Baptist",
"Moravian", # Protestant Christian church movement
"Quaker",
"Methodist",
"Free Church",
"Church of England/Free Church",
"Church of England/Evangelical",
"Church of England/United Reformed Church",
"Anglican/Christian",
"Inter- / non- denominational",
"Seventh Day Adventist",
"Church of England/Christian",
"Church of England/Methodist",
"Congregational Church"].freeze

CATHOLIC_RELIGIOUS_TYPES = ["Roman Catholic",
"Catholic",
"Roman Catholic/Anglican",
"Roman Catholic/Church of England",
"Church of England/Roman Catholic"].freeze

OTHER_RELIGIOUS_TYPES = [
"Jewish",
"Orthodox Jewish",
"Charadi Jewish",
"Islam",
"Muslim",
"Sunni Deobandi",
"Buddhist",
"Sikh",
"Hindu",
"Multi-faith",
].freeze

validates :religious_character, inclusion: {
in: NON_FAITH_RELIGIOUS_CHARACTER_TYPES + CHRISTIAN_RELIGIOUS_TYPES + CATHOLIC_RELIGIOUS_TYPES + OTHER_RELIGIOUS_TYPES,
allow_nil: false,
}
Comment thread
starswan marked this conversation as resolved.

EXCLUDED_DETAILED_SCHOOL_TYPES = [
"Further education",
"Other independent school",
Expand Down Expand Up @@ -51,13 +106,6 @@ class School < Organisation
through: %i[early_years ks1 ks2 ks3 ks4 ks5],
}.freeze

def religious_character
return if !respond_to?(:gias_data) || gias_data.nil?
return if ["None", "Does not apply"].include?(gias_data["ReligiousCharacter (name)"])

gias_data["ReligiousCharacter (name)"]
end

def live_group_vacancies
if part_of_a_trust?
org_ids = [trust.id] + trust.schools.pluck(:id)
Expand All @@ -71,11 +119,11 @@ def live_group_vacancies
end

def faith_school?
religious_character.present?
NON_FAITH_RELIGIOUS_CHARACTER_TYPES.exclude? religious_character
Comment thread
starswan marked this conversation as resolved.
end

def catholic_school?
religious_character&.include?("Catholic") || false
religious_character.in? CATHOLIC_RELIGIOUS_TYPES
end

def key_stages
Expand Down
4 changes: 2 additions & 2 deletions app/services/search/school_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ def apply_school_type_filter(scope)
return scope unless school_types.present?

if school_types.include?("special_school") && school_types.include?("faith_school")
scope.where.not("gias_data ->> 'ReligiousCharacter (name)' IN (?)", Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES)
scope.where.not(religious_character: Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES)
.or(scope.where(detailed_school_type: Organisation::SPECIAL_SCHOOL_TYPES))
elsif school_types.include?("special_school")
scope.where(detailed_school_type: Organisation::SPECIAL_SCHOOL_TYPES)
elsif school_types.include?("faith_school")
scope.where.not("gias_data ->> 'ReligiousCharacter (name)' IN (?)", Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES)
scope.where.not(religious_character: Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES)
else
scope
end
Expand Down
18 changes: 2 additions & 16 deletions spec/factories/schools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"TypeOfEstablishment (code)": "02",
}
end
religious_character { "None" }
detailed_school_type { "Voluntary aided school" }
minimum_age { 11 }
maximum_age { 18 }
Expand Down Expand Up @@ -74,22 +75,7 @@
end

trait :catholic do
gias_data do
{
CloseDate: nil,
HeadFirstName: Faker::Name.first_name,
HeadLastName: Faker::Name.last_name.delete("'"),
HeadPreferredJobTitle: Faker::Name.prefix.delete("."),
DateOfLastInspectionVisit: Faker::Date.between(from: 999.days.ago, to: 5.days.ago),
NumberOfPupils: Faker::Number.number(digits: 3),
"OfstedRating (name)": factory_sample(ofsted_ratings),
OpenDate: Faker::Date.between(from: 10_000.days.ago, to: 1000.days.ago),
"ReligiousCharacter (name)": "Roman Catholic",
SchoolCapacity: Faker::Number.number(digits: 4),
TelephoneNum: Faker::Number.number(digits: 11).to_s,
"Trusts (name)": "#{Faker::Company.name.delete("'")} Trust",
}
end
religious_character { "Roman Catholic" }
end

trait :no_geolocation do
Expand Down
Loading
Loading