Fixed #12761 -- Added Paraguayan local flavor. Thanks, dschulz and BernhardEssl.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16477 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
54552ee29f
commit
f801e2c15d
|
@ -0,0 +1,21 @@
|
|||
"""
|
||||
PY-specific Form helpers.
|
||||
"""
|
||||
from django.forms.fields import Select
|
||||
|
||||
class PyDepartmentSelect(Select):
|
||||
"""
|
||||
A Select widget with a list of Paraguayan departments as choices.
|
||||
"""
|
||||
def __init__(self, attrs=None):
|
||||
from py_department import DEPARTMENT_CHOICES
|
||||
super(PyDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_CHOICES)
|
||||
|
||||
|
||||
class PyNumberedDepartmentSelect(Select):
|
||||
"""
|
||||
A Select widget with a roman numbered list of Paraguayan departments as choices.
|
||||
"""
|
||||
def __init__(self, attrs=None):
|
||||
from py_department import DEPARTMENT_ROMAN_CHOICES
|
||||
super(PyNumberedDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_ROMAN_CHOICES)
|
|
@ -0,0 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# http://www.statoids.com/upy.html
|
||||
|
||||
DEPARTMENT_CHOICES = (
|
||||
('AG', u'Alto Paraguay'),
|
||||
('AA', u'Alto Paraná'),
|
||||
('AM', u'Amambay'),
|
||||
('AS', u'Asunción'),
|
||||
('BQ', u'Boquerón'),
|
||||
('CG', u'Caaguazú'),
|
||||
('CZ', u'Caazapá'),
|
||||
('CY', u'Canindeyú'),
|
||||
('CE', u'Central'),
|
||||
('CN', u'Concepción'),
|
||||
('CR', u'Cordillera'),
|
||||
('GU', u'Guairá'),
|
||||
('IT', u'Itapúa'),
|
||||
('MI', u'Misiones'),
|
||||
('NE', u'Ñeembucú'),
|
||||
('PG', u'Paraguarí'),
|
||||
('PH', u'Pdte. Hayes'),
|
||||
('SP', u'San Pedro'),
|
||||
)
|
||||
|
||||
DEPARTMENT_ROMAN_CHOICES = (
|
||||
('CN', u'I Concepción'),
|
||||
('SP', u'II San Pedro'),
|
||||
('CR', u'III Cordillera'),
|
||||
('GU', u'IV Guairá'),
|
||||
('CG', u'V Caaguazú'),
|
||||
('CZ', u'VI Caazapá'),
|
||||
('IT', u'VII Itapúa'),
|
||||
('MI', u'VIII Misiones'),
|
||||
('PG', u'IX Paraguarí'),
|
||||
('AA', u'X Alto Paraná'),
|
||||
('CE', u'XI Central'),
|
||||
('NE', u'XII Ñeembucú'),
|
||||
('AM', u'XIII Amambay'),
|
||||
('CY', u'XIV Canindeyú'),
|
||||
('PH', u'XV Pdte. Hayes'),
|
||||
('AG', u'XVI Alto Paraguay'),
|
||||
('BQ', u'XVII Boquerón'),
|
||||
('AS', u'XVIII Asunción'),
|
||||
)
|
|
@ -64,6 +64,7 @@ Countries currently supported by :mod:`~django.contrib.localflavor` are:
|
|||
* Peru_
|
||||
* Poland_
|
||||
* Portugal_
|
||||
* Paraguay_
|
||||
* Romania_
|
||||
* Russia_
|
||||
* Slovakia_
|
||||
|
@ -114,6 +115,7 @@ Here's an example of how to use them::
|
|||
.. _Macedonia: `Macedonia (mk)`_
|
||||
.. _Mexico: `Mexico (mx)`_
|
||||
.. _Norway: `Norway (no)`_
|
||||
.. _Paraguay: `Paraguay (py)`_
|
||||
.. _Peru: `Peru (pe)`_
|
||||
.. _Poland: `Poland (pl)`_
|
||||
.. _Portugal: `Portugal (pt)`_
|
||||
|
@ -784,6 +786,19 @@ Norway (``no``)
|
|||
A ``Select`` widget that uses a list of Norwegian municipalities (fylker) as
|
||||
its choices.
|
||||
|
||||
Paraguay (``py``)
|
||||
=================
|
||||
|
||||
.. versionadded:: 1.4
|
||||
|
||||
.. class:: py.forms.PyDepartmentSelect
|
||||
|
||||
A ``Select`` widget with a list of Paraguayan departments as choices.
|
||||
|
||||
.. class:: py.forms.PyNumberedDepartmentSelect
|
||||
|
||||
A ``Select`` widget with a roman numbered list of Paraguayan departments as choices.
|
||||
|
||||
Peru (``pe``)
|
||||
=============
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
from django.contrib.localflavor.py.forms import (PyDepartmentSelect,
|
||||
PyNumberedDepartmentSelect)
|
||||
|
||||
from utils import LocalFlavorTestCase
|
||||
|
||||
class PYLocalFlavorTests(LocalFlavorTestCase):
|
||||
def test_PyDepartmentSelect(self):
|
||||
py = PyDepartmentSelect()
|
||||
out = u'''<select name="department">
|
||||
<option value="AG">Alto Paraguay</option>
|
||||
<option value="AA">Alto Paran\xe1</option>
|
||||
<option value="AM">Amambay</option>
|
||||
<option value="AS">Asunci\xf3n</option>
|
||||
<option value="BQ">Boquer\xf3n</option>
|
||||
<option value="CG">Caaguaz\xfa</option>
|
||||
<option value="CZ">Caazap\xe1</option>
|
||||
<option value="CY">Canindey\xfa</option>
|
||||
<option value="CE">Central</option>
|
||||
<option value="CN">Concepci\xf3n</option>
|
||||
<option value="CR">Cordillera</option>
|
||||
<option value="GU">Guair\xe1</option>
|
||||
<option value="IT">Itap\xfaa</option>
|
||||
<option value="MI">Misiones</option>
|
||||
<option value="NE">\xd1eembuc\xfa</option>
|
||||
<option value="PG">Paraguar\xed</option>
|
||||
<option value="PH">Pdte. Hayes</option>
|
||||
<option value="SP">San Pedro</option>
|
||||
</select>'''
|
||||
self.assertEqual(py.render('department', 'M'), out)
|
||||
|
||||
def test_PyNumberedDepartmentSelect(self):
|
||||
py = PyNumberedDepartmentSelect()
|
||||
out = u'''<select name="department">
|
||||
<option value="CN">I Concepci\xf3n</option>
|
||||
<option value="SP">II San Pedro</option>
|
||||
<option value="CR">III Cordillera</option>
|
||||
<option value="GU">IV Guair\xe1</option>
|
||||
<option value="CG">V Caaguaz\xfa</option>
|
||||
<option value="CZ">VI Caazap\xe1</option>
|
||||
<option value="IT">VII Itap\xfaa</option>
|
||||
<option value="MI">VIII Misiones</option>
|
||||
<option value="PG">IX Paraguar\xed</option>
|
||||
<option value="AA">X Alto Paran\xe1</option>
|
||||
<option value="CE">XI Central</option>
|
||||
<option value="NE">XII \xd1eembuc\xfa</option>
|
||||
<option value="AM" selected="selected">XIII Amambay</option>
|
||||
<option value="CY">XIV Canindey\xfa</option>
|
||||
<option value="PH">XV Pdte. Hayes</option>
|
||||
<option value="AG">XVI Alto Paraguay</option>
|
||||
<option value="BQ">XVII Boquer\xf3n</option>
|
||||
<option value="AS">XVIII Asunci\xf3n</option>
|
||||
</select>'''
|
||||
self.assertEqual(py.render('department', 'AM'), out)
|
|
@ -27,6 +27,7 @@ from localflavor.mk import MKLocalFlavorTests
|
|||
from localflavor.nl import NLLocalFlavorTests
|
||||
from localflavor.pl import PLLocalFlavorTests
|
||||
from localflavor.pt import PTLocalFlavorTests
|
||||
from localflavor.py import PYLocalFlavorTests
|
||||
from localflavor.ro import ROLocalFlavorTests
|
||||
from localflavor.ru import RULocalFlavorTests
|
||||
from localflavor.se import SELocalFlavorTests
|
||||
|
|
|
@ -40,6 +40,7 @@ from regressiontests.forms.localflavortests import (
|
|||
NLLocalFlavorTests,
|
||||
PLLocalFlavorTests,
|
||||
PTLocalFlavorTests,
|
||||
PYLocalFlavorTests,
|
||||
ROLocalFlavorTests,
|
||||
RULocalFlavorTests,
|
||||
SELocalFlavorTests,
|
||||
|
|
Loading…
Reference in New Issue