Ticket #12761: paraguayan_local_flavor_2.diff
File paraguayan_local_flavor_2.diff, 6.7 KB (added by , 13 years ago) |
---|
-
docs/ref/contrib/localflavor.txt
784 784 A ``Select`` widget that uses a list of Norwegian municipalities (fylker) as 785 785 its choices. 786 786 787 Paraguay (``py``) 788 ================= 789 790 .. class:: py.forms.PyDepartmentSelect 791 792 A ``Select`` widget with a list of Paraguayan departments as choices. 793 794 .. class:: py.forms.PyNumeratedDepartmentSelect 795 796 A ``Select`` widget with a roman numerated list of Paraguayan departments as choices. 797 787 798 Peru (``pe``) 788 799 ============= 789 800 -
django/contrib/localflavor/py/py_department.py
1 # -*- coding: utf-8 -*- 2 3 # http://www.statoids.com/upy.html 4 5 DEPARTMENT_CHOICES = ( 6 ('AG', u'Alto Paraguay'), 7 ('AA', u'Alto Paraná'), 8 ('AM', u'Amambay'), 9 ('AS', u'Asunción'), 10 ('BQ', u'Boquerón'), 11 ('CG', u'Caaguazú'), 12 ('CZ', u'Caazapá'), 13 ('CY', u'Canindeyú'), 14 ('CE', u'Central'), 15 ('CN', u'Concepción'), 16 ('CR', u'Cordillera'), 17 ('GU', u'Guairá'), 18 ('IT', u'Itapúa'), 19 ('MI', u'Misiones'), 20 ('NE', u'Ñeembucú'), 21 ('PG', u'Paraguarí'), 22 ('PH', u'Pdte. Hayes'), 23 ('SP', u'San Pedro'), 24 ) 25 26 DEPARTMENT_ROMAN_CHOICES = ( 27 ('CN', u'I Concepción'), 28 ('SP', u'II San Pedro'), 29 ('CR', u'III Cordillera'), 30 ('GU', u'IV Guairá'), 31 ('CG', u'V Caaguazú'), 32 ('CZ', u'VI Caazapá'), 33 ('IT', u'VII Itapúa'), 34 ('MI', u'VIII Misiones'), 35 ('PG', u'IX Paraguarí'), 36 ('AA', u'X Alto Paraná'), 37 ('CE', u'XI Central'), 38 ('NE', u'XII Ñeembucú'), 39 ('AM', u'XIII Amambay'), 40 ('CY', u'XIV Canindeyú'), 41 ('PH', u'XV Pdte. Hayes'), 42 ('AG', u'XVI Alto Paraguay'), 43 ('BQ', u'XVII Boquerón'), 44 ('AS', u'XVIII Asunción'), 45 ) -
django/contrib/localflavor/py/forms.py
1 # -*- coding: utf-8 -*- 2 """ 3 PY-specific Form helpers. 4 """ 5 6 from django.forms import ValidationError 7 from django.forms.fields import RegexField, CharField, Select, EMPTY_VALUES 8 9 class PyDepartmentSelect(Select): 10 """ 11 A Select widget with a list of Paraguayan departments as choices. 12 """ 13 def __init__(self, attrs=None): 14 from py_department import DEPARTMENT_CHOICES 15 super(PyDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_CHOICES) 16 17 18 class PyNumeratedDepartmentSelect(Select): 19 """ 20 A Select widget with a roman numerated list of Paraguayan departments as choices. 21 """ 22 def __init__(self, attrs=None): 23 from py_department import DEPARTMENT_ROMAN_CHOICES 24 super(PyNumeratedDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_ROMAN_CHOICES) -
tests/regressiontests/forms/tests/__init__.py
40 40 NLLocalFlavorTests, 41 41 PLLocalFlavorTests, 42 42 PTLocalFlavorTests, 43 PYLocalFlavorTests, 43 44 ROLocalFlavorTests, 44 45 RULocalFlavorTests, 45 46 SELocalFlavorTests, -
tests/regressiontests/forms/localflavor/py.py
1 from django.contrib.localflavor.py.forms import (PyDepartmentSelect, 2 PyNumeratedDepartmentSelect) 3 4 from utils import LocalFlavorTestCase 5 6 class PYLocalFlavorTests(LocalFlavorTestCase): 7 def test_PyDepartmentSelect(self): 8 py = PyDepartmentSelect() 9 out = u'''<select name="department"> 10 <option value="AG">Alto Paraguay</option> 11 <option value="AA">Alto Paran\xe1</option> 12 <option value="AM">Amambay</option> 13 <option value="AS">Asunci\xf3n</option> 14 <option value="BQ">Boquer\xf3n</option> 15 <option value="CG">Caaguaz\xfa</option> 16 <option value="CZ">Caazap\xe1</option> 17 <option value="CY">Canindey\xfa</option> 18 <option value="CE">Central</option> 19 <option value="CN">Concepci\xf3n</option> 20 <option value="CR">Cordillera</option> 21 <option value="GU">Guair\xe1</option> 22 <option value="IT">Itap\xfaa</option> 23 <option value="MI">Misiones</option> 24 <option value="NE">\xd1eembuc\xfa</option> 25 <option value="PG">Paraguar\xed</option> 26 <option value="PH">Pdte. Hayes</option> 27 <option value="SP">San Pedro</option> 28 </select>''' 29 self.assertEqual(py.render('department', 'M'), out) 30 31 def test_PyNumeratedDepartmentSelect(self): 32 py = PyNumeratedDepartmentSelect() 33 out = u'''<select name="department"> 34 <option value="CN">I Concepci\xf3n</option> 35 <option value="SP">II San Pedro</option> 36 <option value="CR">III Cordillera</option> 37 <option value="GU">IV Guair\xe1</option> 38 <option value="CG">V Caaguaz\xfa</option> 39 <option value="CZ">VI Caazap\xe1</option> 40 <option value="IT">VII Itap\xfaa</option> 41 <option value="MI">VIII Misiones</option> 42 <option value="PG">IX Paraguar\xed</option> 43 <option value="AA">X Alto Paran\xe1</option> 44 <option value="CE">XI Central</option> 45 <option value="NE">XII \xd1eembuc\xfa</option> 46 <option value="AM" selected="selected">XIII Amambay</option> 47 <option value="CY">XIV Canindey\xfa</option> 48 <option value="PH">XV Pdte. Hayes</option> 49 <option value="AG">XVI Alto Paraguay</option> 50 <option value="BQ">XVII Boquer\xf3n</option> 51 <option value="AS">XVIII Asunci\xf3n</option> 52 </select>''' 53 self.assertEqual(py.render('department', 'AM'), out) -
tests/regressiontests/forms/localflavortests.py
27 27 from localflavor.nl import NLLocalFlavorTests 28 28 from localflavor.pl import PLLocalFlavorTests 29 29 from localflavor.pt import PTLocalFlavorTests 30 from localflavor.py import PYLocalFlavorTests 30 31 from localflavor.ro import ROLocalFlavorTests 31 32 from localflavor.ru import RULocalFlavorTests 32 33 from localflavor.se import SELocalFlavorTests