-
Notifications
You must be signed in to change notification settings - Fork 27
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
Validate course number #318
base: master
Are you sure you want to change the base?
Conversation
@@ -13,6 +13,8 @@ module Pbs::Event::Course | |||
APPROVALS = %w(requires_approval_abteilung requires_approval_region | |||
requires_approval_kantonalverband requires_approval_bund).freeze | |||
|
|||
COURSE_NUMBER_REGEX = /\APBS CH(?: [A-Z]{2})? [0-9]{3}-[0-9]{2}\z/.freeze |
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.
Following what's specified in https://pilot.scouts.ch (page 12 in the current version)
if: :validate_number? } | ||
|
||
def validate_number? | ||
(new_record? || number_changed? || kind_id_changed?) && kind.validate_course_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.
It should be possible to update existing records as long as course number and event kind are left untouched
578d877
to
7201c7c
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.
Schaut gut aus!
Habs jetzt noch nicht manuell getestet & wäre sicher super wenn der CI durchlaufen würde. Als Tipp hilft hoffentlich mein Kommentar bei der Migration :)
if: :validate_number? } | ||
|
||
def validate_number? | ||
(new_record? || number_changed? || kind_id_changed?) && kind.validate_course_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.
(new_record? || number_changed? || kind_id_changed?) && kind.validate_course_number | |
return false unless kind.validate_course_number? | |
new_record? || | |
number_changed? || | |
kind_id_changed? |
Find ich persönlich leserlicher
…kinds.rb Co-authored-by: Nils Rauch <[email protected]>
No description provided.