-
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
base: main
Are you sure you want to change the base?
feat: add School Roll Number field for Ireland schools Add optional s… #632
Conversation
…chool_roll_number field with alphanumeric validation, following the same pattern as UK URN and US district fields. Includes database migration, API endpoints, admin dashboard integration, and comprehensive test coverage.
0725649 to
da5cab5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds an optional school_roll_number field for Ireland schools, following the established pattern used for UK reference numbers (URN) and US district fields. The implementation includes database migration with unique indexing, model validation with alphanumeric format enforcement, API endpoint integration, admin dashboard support, and comprehensive model-level test coverage.
Key changes:
- Added
school_roll_numbercolumn to schools table with unique index for efficient lookups and duplicate prevention - Implemented case-insensitive uniqueness validation and alphanumeric format requirement (numbers followed by letters)
- Integrated field throughout the API stack (REST endpoints, JSON responses, admin dashboard)
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
db/migrate/20251128102719_add_school_roll_number_to_schools.rb |
Migration adding school_roll_number column with unique index |
db/schema.rb |
Schema update reflecting new column and index |
app/models/school.rb |
Validation rules (uniqueness, format), normalization callback for blank values |
app/controllers/api/schools_controller.rb |
Added school_roll_number to permitted parameters |
app/views/api/schools/_school.json.jbuilder |
Included school_roll_number in JSON API responses |
app/dashboards/school_dashboard.rb |
Added field to admin dashboard attributes (show, form) |
config/locales/en.yml |
Added validation error message for format requirements |
spec/models/school_spec.rb |
8 comprehensive tests covering optional field, uniqueness, format validation, normalization |
spec/factories/school.rb |
Added school_roll_number attribute with nil default |
spec/features/my_school/showing_my_school_spec.rb |
Updated expected JSON fields to include school_roll_number |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
config/locales/en.yml
Outdated
| validations: | ||
| school: | ||
| website: "must be a valid URL" | ||
| school_roll_number: "must be alphanumeric (e.g., 01572D)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure this is the best error message, as the tests show that we are precluding strings that contain either all letters or all numbers, which are still alphanumeric
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, on this, where are you thinking that this error message will be surfaced? Because we need to ensure that it's still translatable on the frontend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking closer the backend validation messages aren't currently shown inline to users, they see a generic 'Please check the fields' alert instead. The frontend handles user facing error messages with translations (similar to how the website field works). I'll update the backend message to be more accurate for logging/API purposes: "must be numbers followed by letters (e.g., 01572D)" which matches the actual Irish School Roll Number format from the official government database. I'll follow the existing pattern used for the website URL field and have a translatable key on the frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most likely we'll want to be catching this on the frontend anyway
| 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') } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
In the Department’s datasets, roll numbers consistently appear as 5 digits followed by an uppercase letter (e.g. 01572D).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay great, thanks for looking into this 👍
… reapplication with the same roll number after a school is rejected
…reuse. Aligns database constraint with application validation by only enforcing uniqueness where rejected_at IS NULL
…l presence validation so school_roll_number is required when country_code is IE, following existing pattern for UK postal codes.
danhalson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add School Roll Number field for Ireland schools
Add optional school_roll_number field with alphanumeric validation, following the same pattern as UK URN and US district fields. Includes database migration, API endpoints, admin dashboard integration, and comprehensive test coverage.
Status
Closes: https://github.com/orgs/RaspberryPiFoundation/projects/51/views/11?pane=issue&itemId=132315256&issue=RaspberryPiFoundation%7Cdigital-editor-issues%7C925
Related to: https://github.com/RaspberryPiFoundation/editor-standalone/pull/686
Points for consideration:
Security
Performance
school_roll_numbercolumn for efficient lookupsWhat's changed?
Database:
school_roll_numberstring column toschoolstableschool_roll_numberModel (School):
API:
school_roll_numberto permitted parameters in SchoolsControllerschool_roll_numberin JSON API responsesAdmin Dashboard:
Tests:
Locales:
config/locales/en.yml