Closed grensjo closed 2 years ago
The validation error is not a translatable string, otherwise the code looks good.
I'm not sure about forcing the user to enter a "valid" phonenumber though. As numbering plans change, we are forced to make sure that libphonenumber is updated or users risk not being able to enter their phone number. The risk is of course low, but the risk increases with each change in the numbering plans of every country if we don't keep it up to date.
Can we instead warn the user that it looks like an invalid number and won't work in sqrubbentelefonen? Or maybe have like a "✅ Sqrubben phone compatible" thing by the phone number. Or just explain during entry that it has to contain the country code if it is not swedish? Either way we should probably do the latter, entering a non-swedish number and just getting "invalid number" is not very nice.
Good point! What do you think about this solution? I removed the validation and instead clarified the phone field description, as well as added a warning for invalid phone numbers on the profile page (visible only to the user themselves and admins).
I'll leave out the bit about Sqrubbentelefonen at least until the integration is launched. After that we could add the "Verified Sqrubben phone compatible" checkmark or something similar. That could help with getting the word out there about the feature as well!
Cool cool cool!
Add form validation to ensure valid phone numbers are entered, and a custom setter in the User model, automatically normalizing numbers when they are set.
Further, a script is added to normalize phone numbers in an existing database. Simply run
flask scripts normalize_phone_numbers
to execute it.Additionally, update the test database to have valid but still unused phone numbers, as well as one user without a phone number. The old numbers for Monty Python and Rick Astley used the 071 area code, which the phonenumber library doesn't like. The replacement numbers are taken from the PTS list of phone numbers to use in books, movies, etc. :)
The purpose of this change is to enable searching for users by phone number, which will be needed for integration with Sqrubbentelefonen.