Skip to content

Commit

Permalink
Add email to eligible_fe_providers
Browse files Browse the repository at this point in the history
When a claimant submits an FE claim we need to email a contact at the
organisation the claimant is claiming for.
The contact email of the organisation will be captured in the FE
provider CSV.
We've gone with the name `primary_key_contact_email_address` for storing
the FE provider contact email address to match the attribute name on
eligible_ey_providers.
We've updated the existing fixture csv to set the contact email address
on review apps to the shared claim team gmail account (along with the
ukprn of the organisation being applied for).
  • Loading branch information
rjlynch committed Aug 22, 2024
1 parent 85ebb40 commit debfb9e
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 293 deletions.
7 changes: 6 additions & 1 deletion app/models/eligible_fe_provider.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
class EligibleFeProvider < ApplicationRecord
attribute :academic_year, AcademicYear::Type.new

validates :primary_key_contact_email_address,
presence: true,
format: {with: Rails.application.config.email_regexp},
length: {maximum: 256}

def self.csv_for_academic_year(academic_year)
attribute_names = [:ukprn, :max_award_amount, :lower_award_amount]
attribute_names = [:ukprn, :max_award_amount, :lower_award_amount, :primary_key_contact_email_address]

CSV.generate(headers: true) do |csv|
csv << attribute_names
Expand Down
2 changes: 2 additions & 0 deletions app/models/eligible_fe_providers_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class EligibleFeProvidersImporter < CsvImporter::Base
ukprn
max_award_amount
lower_award_amount
primary_key_contact_email_address
]
)

Expand All @@ -32,6 +33,7 @@ def row_to_hash(row)
ukprn: row.fetch("ukprn"),
max_award_amount: row.fetch("max_award_amount"),
lower_award_amount: row.fetch("lower_award_amount"),
primary_key_contact_email_address: row.fetch("primary_key_contact_email_address"),
academic_year:
}
end
Expand Down
2 changes: 2 additions & 0 deletions config/analytics_blocklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
- secondary_contact_email_address
- created_at
- updated_at
:eligible_fe_providers:
- primary_key_contact_email_address
:schools:
- postcode_sanitised
:file_uploads:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPrimaryContactEmailAddressToEligileFeProviders < ActiveRecord::Migration[7.0]
def change
add_column :eligible_fe_providers, :primary_key_contact_email_address, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_08_16_122950) do
ActiveRecord::Schema[7.0].define(version: 2024_08_21_121253) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_trgm"
Expand Down Expand Up @@ -207,6 +207,7 @@
t.decimal "lower_award_amount", precision: 7, scale: 2
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "primary_key_contact_email_address"
t.index ["academic_year", "ukprn"], name: "index_eligible_fe_providers_on_academic_year_and_ukprn"
end

Expand Down
1 change: 1 addition & 0 deletions spec/factories/eligible_fe_providers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
academic_year { AcademicYear.current }
max_award_amount { [4_000, 5_000, 6_000].sample }
lower_award_amount { [2_000, 2_500, 3_000].sample }
primary_key_contact_email_address { Faker::Internet.email }
end
end
2 changes: 1 addition & 1 deletion spec/features/admin/eligible_fe_providers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def eligible_fe_providers_csv_file

3.times do
hash = attributes_for(:eligible_fe_provider)
@eligible_fe_providers_csv_file.write "#{hash[:ukprn]},#{hash[:max_award_amount].to_f},#{hash[:lower_award_amount].to_f}\n"
@eligible_fe_providers_csv_file.write "#{hash[:ukprn]},#{hash[:max_award_amount].to_f},#{hash[:lower_award_amount].to_f},#{hash[:primary_key_contact_email_address]}\n"
end

@eligible_fe_providers_csv_file.rewind
Expand Down
Loading

0 comments on commit debfb9e

Please sign in to comment.