summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-12-02 20:41:30 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-12-02 20:41:30 +0000
commit2881007ad469900e9b7178a58a052f29cb6c6849 (patch)
treea9c53078c8d79635064ef85eb9a219a66d2a0b5a
parentd25d6b3f86b3a53306ab144596dbe8e5d96aa112 (diff)
Fixed #5676 -- Added Mexican localflavor. Thanks, arien.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6847 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/localflavor/mx/__init__.py0
-rw-r--r--django/contrib/localflavor/mx/forms.py14
-rw-r--r--django/contrib/localflavor/mx/mx_states.py45
3 files changed, 59 insertions, 0 deletions
diff --git a/django/contrib/localflavor/mx/__init__.py b/django/contrib/localflavor/mx/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/django/contrib/localflavor/mx/__init__.py
diff --git a/django/contrib/localflavor/mx/forms.py b/django/contrib/localflavor/mx/forms.py
new file mode 100644
index 0000000000..5e42cca7d7
--- /dev/null
+++ b/django/contrib/localflavor/mx/forms.py
@@ -0,0 +1,14 @@
+"""
+Mexican-specific form helpers.
+"""
+
+from django.newforms.fields import Select
+
+class MXStateSelect(Select):
+ """
+ A Select widget that uses a list of Mexican states as its choices.
+ """
+ def __init__(self, attrs=None):
+ from mx_states import STATE_CHOICES
+ super(MXStateSelect, self).__init__(attrs, choices=STATE_CHOICES)
+
diff --git a/django/contrib/localflavor/mx/mx_states.py b/django/contrib/localflavor/mx/mx_states.py
new file mode 100644
index 0000000000..eed1700efb
--- /dev/null
+++ b/django/contrib/localflavor/mx/mx_states.py
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+"""
+A list of Mexican states for use as `choices` in a formfield.
+
+This exists in this standalone file so that it's only imported into memory
+when explicitly needed.
+"""
+
+from django.utils.translation import ugettext_lazy as _
+
+STATE_CHOICES = (
+ ('AGU', _(u'Aguascalientes')),
+ ('BCN', _(u'Baja California')),
+ ('BCS', _(u'Baja California Sur')),
+ ('CAM', _(u'Campeche')),
+ ('CHH', _(u'Chihuahua')),
+ ('CHP', _(u'Chiapas')),
+ ('COA', _(u'Coahuila')),
+ ('COL', _(u'Colima')),
+ ('DIF', _(u'Distrito Federal')),
+ ('DUR', _(u'Durango')),
+ ('GRO', _(u'Guerrero')),
+ ('GUA', _(u'Guanajuato')),
+ ('HID', _(u'Hidalgo')),
+ ('JAL', _(u'Jalisco')),
+ ('MEX', _(u'Estado de México')),
+ ('MIC', _(u'Michoacán')),
+ ('MOR', _(u'Morelos')),
+ ('NAY', _(u'Nayarit')),
+ ('NLE', _(u'Nuevo León')),
+ ('OAX', _(u'Oaxaca')),
+ ('PUE', _(u'Puebla')),
+ ('QUE', _(u'Querétaro')),
+ ('ROO', _(u'Quintana Roo')),
+ ('SIN', _(u'Sinaloa')),
+ ('SLP', _(u'San Luis Potosí')),
+ ('SON', _(u'Sonora')),
+ ('TAB', _(u'Tabasco')),
+ ('TAM', _(u'Tamaulipas')),
+ ('TLA', _(u'Tlaxcala')),
+ ('VER', _(u'Veracruz')),
+ ('YUC', _(u'Yucatán')),
+ ('ZAC', _(u'Zacatecas')),
+)
+