django / django-localflavor

Country-specific Django helpers, formerly of contrib fame
https://django-localflavor.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
812 stars 289 forks source link

fix: Accept French Postal Services identifiers in forms #505

Open Chatewgne opened 3 months ago

Chatewgne commented 3 months ago

This PR is intended to fix the following issue : https://github.com/django/django-localflavor/issues/504

The form validation in FRSIRENENumberMixin is missing a special case from the SIRENE register.

The identifiers for Postal Services need a special validation process and are not currently validated.

Source (in french) : https://www.sirene.fr/static-resources/doc/lettres/lettre-16-novembre-2013.pdf

All Changes

claudep commented 2 months ago

Sorry for the delay for reviewing, could you please add/complement a test for this?

Chatewgne commented 2 months ago

Thanks for getting back to me @claudep, I have added the test cases :)

benkonrath commented 1 month ago

The exception only applies to SIRET, not to SIREN, so this update isn't correct. I think we should remove the mixin and use stdnum to validate both of the fields directly in the form class. This would add few lines of common code to both classes but it makes things clearer.