Code

Opened 4 years ago

Closed 18 months ago

#14308 closed New feature (invalid)

Adding some fields to the Mexican local flavor.

Reported by: srpoder 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)

forms.py (1.5 KB) - added by srpoder 4 years ago.
The same as above in the description.

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by srpoder

The same as above in the description.

comment:1 Changed 4 years ago by d0ugal

  • Has patch set
  • Needs documentation unset
  • 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 Changed 3 years ago by russellm

  • milestone 1.3 deleted
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:6 Changed 18 months ago by aaugustin

  • Keywords Mexican, Fields, localflavorsplit added; Mexican Fields removed
  • Resolution set to invalid
  • Status changed from new to 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!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.