Ticket #12761: paraguayan_local_flavor.diff

File paraguayan_local_flavor.diff, 6.5 KB (added by Bernhard Essl, 13 years ago)
  • docs/ref/contrib/localflavor.txt

     
    784784    A ``Select`` widget that uses a list of Norwegian municipalities (fylker) as
    785785    its choices.
    786786
     787Paraguay (``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
    787798Peru (``pe``)
    788799=============
    789800
  • django/contrib/localflavor/py/py_department.py

     
     1# -*- coding: utf-8 -*-
     2
     3DEPARTMENT_CHOICES = (
     4    ('A', u'Concepción'),
     5    ('B', u'San Pedro'),
     6    ('C', u'Cordillera'),
     7    ('D', u'Guairá'),
     8    ('E', u'Caaguazú'),
     9    ('F', u'Caazapá'),
     10    ('G', u'Itapúa'),
     11    ('H', u'Misiones'),
     12    ('I', u'Paraguarí'),
     13    ('J', u'Alto Paraná'),
     14    ('K', u'Central'),
     15    ('L', u'Ñeembucú'),
     16    ('M', u'Amambay'),
     17    ('N', u'Canindeyú'),
     18    ('O', u'Pdte. Hayes'),
     19    ('P', u'Alto Paraguay'),
     20    ('Q', u'Boquerón'),
     21)
     22
     23DEPARTMENT_ROMAN_CHOICES = (
     24    ('A',  u'I    Concepción'),
     25    ('B',  u'II   San Pedro'),
     26    ('C',  u'III  Cordillera'),
     27    ('D',  u'IV   Guairá'),
     28    ('E',  u'V    Caaguazú'),
     29    ('F',  u'VI   Caazapá'),
     30    ('G',  u'VII  Itapúa'),
     31    ('H',  u'VIII Misiones'),
     32    ('I',  u'IX   Paraguarí'),
     33    ('J',  u'X    Alto Paraná'),
     34    ('K',  u'XI   Central'),
     35    ('L',  u'XII  Ñeembucú'),
     36    ('M',  u'XIII Amambay'),
     37    ('N',  u'XIV  Canindeyú'),
     38    ('O',  u'XV   Pdte. Hayes'),
     39    ('P',  u'XVI  Alto Paraguay'),
     40    ('Q',  u'XVII Boquerón'),
     41)
  • django/contrib/localflavor/py/forms.py

     
     1# -*- coding: utf-8 -*-
     2"""
     3PY-specific Form helpers.
     4"""
     5
     6from django.forms import ValidationError
     7from django.forms.fields import RegexField, CharField, Select, EMPTY_VALUES
     8
     9class 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
     18class 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

     
    4040    NLLocalFlavorTests,
    4141    PLLocalFlavorTests,
    4242    PTLocalFlavorTests,
     43    PYLocalFlavorTests,
    4344    ROLocalFlavorTests,
    4445    RULocalFlavorTests,
    4546    SELocalFlavorTests,
  • tests/regressiontests/forms/localflavor/py.py

     
     1from django.contrib.localflavor.py.forms import (PyDepartmentSelect,
     2    PyNumeratedDepartmentSelect)
     3
     4from utils import LocalFlavorTestCase
     5
     6class PYLocalFlavorTests(LocalFlavorTestCase):
     7    def test_PyDepartmentSelect(self):
     8        py = PyDepartmentSelect()
     9        out = u'''<select name="department">
     10<option value="A">Concepci\xf3n</option>
     11<option value="B">San Pedro</option>
     12<option value="C">Cordillera</option>
     13<option value="D">Guair\xe1</option>
     14<option value="E">Caaguaz\xfa</option>
     15<option value="F">Caazap\xe1</option>
     16<option value="G">Itap\xfaa</option>
     17<option value="H">Misiones</option>
     18<option value="I">Paraguar\xed</option>
     19<option value="J">Alto Paran\xe1</option>
     20<option value="K">Central</option>
     21<option value="L">\xd1eembuc\xfa</option>
     22<option value="M" selected="selected">Amambay</option>
     23<option value="N">Canindey\xfa</option>
     24<option value="O">Pdte. Hayes</option>
     25<option value="P">Alto Paraguay</option>
     26<option value="Q">Boquer\xf3n</option>
     27</select>'''
     28        self.assertEqual(py.render('department', 'M'), out)
     29
     30    def test_PyNumeratedDepartmentSelect(self):
     31        py = PyNumeratedDepartmentSelect()
     32        out = u'''<select name="department">
     33<option value="A">I    Concepci\xf3n</option>
     34<option value="B">II   San Pedro</option>
     35<option value="C">III  Cordillera</option>
     36<option value="D">IV   Guair\xe1</option>
     37<option value="E">V    Caaguaz\xfa</option>
     38<option value="F">VI   Caazap\xe1</option>
     39<option value="G">VII  Itap\xfaa</option>
     40<option value="H">VIII Misiones</option>
     41<option value="I">IX   Paraguar\xed</option>
     42<option value="J">X    Alto Paran\xe1</option>
     43<option value="K">XI   Central</option>
     44<option value="L">XII  \xd1eembuc\xfa</option>
     45<option value="M" selected="selected">XIII Amambay</option>
     46<option value="N">XIV  Canindey\xfa</option>
     47<option value="O">XV   Pdte. Hayes</option>
     48<option value="P">XVI  Alto Paraguay</option>
     49<option value="Q">XVII Boquer\xf3n</option>
     50</select>'''
     51        self.assertEqual(py.render('department', 'M'), out)
  • tests/regressiontests/forms/localflavortests.py

     
    2727from localflavor.nl import NLLocalFlavorTests
    2828from localflavor.pl import PLLocalFlavorTests
    2929from localflavor.pt import PTLocalFlavorTests
     30from localflavor.py import PYLocalFlavorTests
    3031from localflavor.ro import ROLocalFlavorTests
    3132from localflavor.ru import RULocalFlavorTests
    3233from localflavor.se import SELocalFlavorTests
Back to Top