-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add School Roll Number field for Ireland schools Add optional s… #632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
277a408
efe6780
da5cab5
d9b33fe
05481ed
8fe2f36
6a375d2
da062e6
dba5faf
84d8def
fb572cc
4abee07
116dd1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,10 @@ class School < ApplicationRecord | |
| validates :country_code, presence: true, inclusion: { in: ISO3166::Country.codes } | ||
| validates :reference, uniqueness: { case_sensitive: false, allow_nil: true }, presence: false | ||
| validates :district_nces_id, uniqueness: { case_sensitive: false, allow_nil: true }, presence: false | ||
| validates :school_roll_number, | ||
| uniqueness: { case_sensitive: false, allow_nil: true }, | ||
| presence: false, | ||
| format: { with: /\A[0-9]+[A-Z]+\z/, allow_nil: true, message: I18n.t('validations.school.school_roll_number') } | ||
Mohamed-RPF marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a reference anywhere that shows us what the format of an Irish school roll number should be so we can verify this regex is correct?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 3rd AC in the ticket mentions 'Given the "School Roll Number" field is visible, when I enter a valid alpha-numeric value (e.g., 01572D), then the data is accepted and saved with the application.'
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that example meant to show what the precise format will be? I was thinking more of something official
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are some examples from the gov.ie website: 20375I, 20374G, 20378O, 20371A
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked public sources and there’s no official published spec for the roll-number format.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay great, thanks for looking into this 👍 |
||
| validates :creator_id, presence: true, uniqueness: true | ||
| validates :creator_agree_authority, presence: true, acceptance: true | ||
| validates :creator_agree_terms_and_conditions, presence: true, acceptance: true | ||
|
|
@@ -34,6 +38,7 @@ class School < ApplicationRecord | |
|
|
||
| before_validation :normalize_reference | ||
| before_validation :normalize_district_fields | ||
| before_validation :normalize_school_roll_number | ||
|
|
||
| before_save :format_uk_postal_code, if: :should_format_uk_postal_code? | ||
|
|
||
|
|
@@ -102,6 +107,12 @@ def normalize_district_fields | |
| self.district_nces_id = nil if district_nces_id.blank? | ||
| end | ||
|
|
||
| # Ensure the school_roll_number is nil, not an empty string | ||
| # Also normalize to uppercase for consistent validation | ||
| def normalize_school_roll_number | ||
| self.school_roll_number = school_roll_number.blank? ? nil : school_roll_number.upcase | ||
| end | ||
|
|
||
| def verified_at_cannot_be_changed | ||
| errors.add(:verified_at, 'cannot be changed after verification') if verified_at_was.present? && verified_at_changed? | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ en: | |
| validations: | ||
| school: | ||
| website: "must be a valid URL" | ||
| school_roll_number: "must be alphanumeric (e.g., 01572D)" | ||
|
||
| invitation: | ||
| email_address: "'%<value>s' is invalid" | ||
| activerecord: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class AddSchoolRollNumberToSchools < ActiveRecord::Migration[7.2] | ||
| def change | ||
| add_column :schools, :school_roll_number, :string | ||
|
|
||
| add_index :schools, :school_roll_number, unique: true | ||
Mohamed-RPF marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
| end | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.