Permalink
Browse files

Fixed #4808 -- Added Chilean regions in localflavor. Thanks, Marijn V…

…riens <marijn@metronomo.cl>.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5663 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
freakboy3742 committed Jul 12, 2007
1 parent 1655103 commit f3e71048c3e6b3c932586e3ec45a55986f90f63c
View
@@ -175,7 +175,7 @@ answer newbie questions, and generally made Django that much better:
Manuzhai Manuzhai
Petar Marić <http://www.petarmaric.com/> Petar Marić <http://www.petarmaric.com/>
Nuno Mariz <nmariz@gmail.com> Nuno Mariz <nmariz@gmail.com>
marijn@metronomo.cl Marijn Vriens <marijn@metronomo.cl>
mark@junklight.com mark@junklight.com
Yasushi Masuda <whosaysni@gmail.com> Yasushi Masuda <whosaysni@gmail.com>
mattycakes@gmail.com mattycakes@gmail.com
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
A list of Chilean regions as `choices` in a formfield.
This exists in this standalone file so that it's only imported into memory
when explicitly needed.
"""
REGION_CHOICES = (
('RM', u'Región Metropolitana de Santiago'),
('I', u'Región de Tarapacá'),
('II', u'Región de Antofagasta'),
('III', u'Región de Atacama'),
('IV', u'Región de Coquimbo'),
('V', u'Región de Valparaíso'),
('VI', u'Región del Libertador Bernardo O\'Higgins'),
('VII', u'Región del Maule'),
('VIII',u'Región del Bío Bío'),
('IX', u'Región de la Araucanía'),
('X', u'Región de los Lagos'),
('XI', u'Región de Aysén del General Carlos Ibáñez del Campo'),
('XII', u'Región de Magallanes y la Antártica Chilena'),
('XIV', u'Región de Los Ríos'),
('XV', u'Región de Arica-Parinacota'),
)
@@ -3,10 +3,20 @@
""" """
from django.newforms import ValidationError from django.newforms import ValidationError
from django.newforms.fields import RegexField, EMPTY_VALUES from django.newforms.fields import RegexField, Select, EMPTY_VALUES
from django.utils.translation import ugettext from django.utils.translation import ugettext
from django.utils.encoding import smart_unicode from django.utils.encoding import smart_unicode
class CLRegionSelect(Select):
"""
A Select widget that uses a list of Chilean Regions (Regiones)
as its choices.
"""
def __init__(self, attrs=None):
from cl_regions import REGION_CHOICES
super(CLRegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class CLRutField(RegexField): class CLRutField(RegexField):
""" """
Chilean "Rol Unico Tributario" (RUT) field. This is the Chilean national Chilean "Rol Unico Tributario" (RUT) field. This is the Chilean national
@@ -1356,4 +1356,12 @@
... ...
ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.'] ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.']
## CLRegionSelect #########################################################
>>> from django.contrib.localflavor.cl.forms import CLRegionSelect
>>> f = CLRegionSelect()
>>> f.render('foo', 'bar')
u'<select name="foo">\n<option value="RM">Regi\xf3n Metropolitana de Santiago</option>\n<option value="I">Regi\xf3n de Tarapac\xe1</option>\n<option value="II">Regi\xf3n de Antofagasta</option>\n<option value="III">Regi\xf3n de Atacama</option>\n<option value="IV">Regi\xf3n de Coquimbo</option>\n<option value="V">Regi\xf3n de Valpara\xedso</option>\n<option value="VI">Regi\xf3n del Libertador Bernardo O&#39;Higgins</option>\n<option value="VII">Regi\xf3n del Maule</option>\n<option value="VIII">Regi\xf3n del B\xedo B\xedo</option>\n<option value="IX">Regi\xf3n de la Araucan\xeda</option>\n<option value="X">Regi\xf3n de los Lagos</option>\n<option value="XI">Regi\xf3n de Ays\xe9n del General Carlos Ib\xe1\xf1ez del Campo</option>\n<option value="XII">Regi\xf3n de Magallanes y la Ant\xe1rtica Chilena</option>\n<option value="XIV">Regi\xf3n de Los R\xedos</option>\n<option value="XV">Regi\xf3n de Arica-Parinacota</option>\n</select>'
""" """

0 comments on commit f3e7104

Please sign in to comment.