Opened 15 years ago
Closed 13 years ago
#14308 closed New feature (invalid)
Adding some fields to the Mexican local flavor.
| Reported by: | Andrés Torres | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.localflavor | Version: | 1.2 |
| Severity: | Normal | Keywords: | Mexican, Fields, localflavorsplit |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | yes | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
Fields like RFC, CURP and the ZIP Code are in this file attachment and in the code block here down.
"""
MX-specific Form helpers
"""
from django.forms.fields import RegexField
class MXRFCField(RegexField):
"""
A field that accepts a 'classic' MX RFC (Registro Federal de Contribuyentes).
More info about this: http://es.wikipedia.org/wiki/Registo_Federal_de_Contribuyentes_(M%C3%A9xico)
"""
def __init__(self, *args, **kwargs):
super(MXRFCField, self).__init__(r'^[a-zA-Z]{3}[a-zA-Z\d]?(\d\d)(0[\d]{1}|1[0-2]{1})(0[\d]{1}|[1-2]{1}\d|3[0-1])[a-zA-Z\d]{3}$', *args, **kwargs)
def clean(self, value):
value = super(MXRFCField, self).clean(value)
return value.upper()
class MXCURPField(RegexField):
"""
A field that accepts a 'classic' MX CURP (Clave Unica de Registro de Poblacion).
More info about this: http://es.wikipedia.org/wiki/Clave_%C3%9Anica_de_Registro_de_Poblaci%C3%B3n_%28M%C3%A9xico%29
"""
def __init__(self, *args, **kwargs):
super(MXCURPField, self).__init__(r'^[a-zA-Z]{4}(\d\d)(0[\d]{1}|1[0-2]{1})(0[\d]{1}|[1-2]{1}\d|3[0-1])([hmHM]{1})[a-zA-Z]{5}\d{2}$', *args, **kwargs)
def clean(self, value):
value = super(MXCURPField, self).clean(value)
return value.upper()
class MXZIPCodeField(RegexField):
"""
A field that accepts a 'classic' MX ZIP Code.
More info about this: http://es.wikipedia.org/wiki/C%C3%B3digo_postal_mexicano
"""
def __init__(self, *args, **kwargs):
super(MXZIPCodeField, self).__init__(r'^(\d){5}$', *args, **kwargs)
Thanks.
Attachments (1)
Change History (7)
by , 15 years ago
comment:1 by , 15 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Patch needs improvement: | set |
Presumably we will need tests to show that these work and documentation too.
It would be better to add a patch (svn diff) rather than a file as its easier for commiters to apply.
comment:2 by , 15 years ago
| milestone: | 1.3 |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:3 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → New feature |
comment:6 by , 13 years ago
| Keywords: | localflavorsplit added |
|---|---|
| Resolution: | → invalid |
| Status: | new → closed |
django.contrib.localflavor is now deprecated — see https://docs.djangoproject.com/en/dev/ref/contrib/localflavor/
A repository was created for each localflavor at https://github.com/django/django-localflavor-? (Replace with the country code.)
If you're still interested in this ticket, could you create a pull request on that repository?
Sorry for not resolving this issue earlier, and thanks for your input!
The same as above in the description.