diff --git a/django/contrib/localflavor/ie/__init__.py b/django/contrib/localflavor/ie/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/django/contrib/localflavor/ie/forms.py b/django/contrib/localflavor/ie/forms.py new file mode 100644 index 00000000000..2cfd2f2bcc0 --- /dev/null +++ b/django/contrib/localflavor/ie/forms.py @@ -0,0 +1,13 @@ +""" +UK-specific Form helpers +""" + +from django.forms.fields import Select + +class IECountySelect(Select): + """ + A Select widget that uses a list of Irish Counties as its choices. + """ + def __init__(self, attrs=None): + from ie_counties import IE_COUNTY_CHOICES + super(IECountySelect, self).__init__(attrs, choices=IE_COUNTY_CHOICES) diff --git a/django/contrib/localflavor/ie/ie_counties.py b/django/contrib/localflavor/ie/ie_counties.py new file mode 100644 index 00000000000..c8991e01ae1 --- /dev/null +++ b/django/contrib/localflavor/ie/ie_counties.py @@ -0,0 +1,40 @@ +""" +Sources: + Irish Counties: http://en.wikipedia.org/wiki/Counties_of_Ireland +""" +from django.utils.translation import ugettext_lazy as _ + +IE_COUNTY_CHOICES = ( + ('antrim', _('Antrim')), + ('armagh', _('Armagh')), + ('carlow', _('Carlow')), + ('cavan', _('Cavan')), + ('clare', _('Clare')), + ('cork', _('Cork')), + ('derry', _('Derry')), + ('donegal', _('Donegal')), + ('down', _('Down')), + ('dublin', _('Dublin')), + ('fermanagh', _('Fermanagh')), + ('galway', _('Galway')), + ('kerry', _('Kerry')), + ('kildare', _('Kildare')), + ('kilkenny', _('Kilkenny')), + ('laois', _('Laois')), + ('leitrim', _('Leitrim')), + ('limerick', _('Limerick')), + ('longford', _('Longford')), + ('louth', _('Louth')), + ('mayo', _('Mayo')), + ('meath', _('Meath')), + ('monaghan', _('Monaghan')), + ('offaly', _('Offaly')), + ('roscommon', _('Roscommon')), + ('sligo', _('Sligo')), + ('tipperary', _('Tipperary')), + ('tyrone', _('Tyrone')), + ('waterford', _('Waterford')), + ('westmeath', _('Westmeath')), + ('wexford', _('Wexford')), + ('wicklow', _('Wicklow')), +) diff --git a/docs/ref/contrib/localflavor.txt b/docs/ref/contrib/localflavor.txt index 0b4b9f11fb1..3ba48e1069f 100644 --- a/docs/ref/contrib/localflavor.txt +++ b/docs/ref/contrib/localflavor.txt @@ -50,6 +50,7 @@ Countries currently supported by :mod:`~django.contrib.localflavor` are: * Germany_ * Iceland_ * India_ + * Ireland_ * Italy_ * Japan_ * Kuwait_ @@ -94,6 +95,7 @@ Here's an example of how to use them:: .. _The Netherlands: `The Netherlands (nl)`_ .. _Iceland: `Iceland (is\_)`_ .. _India: `India (in\_)`_ +.. _Ireland: `Ireland (ie)`_ .. _Italy: `Italy (it)`_ .. _Japan: `Japan (jp)`_ .. _Kuwait: `Kuwait (kw)`_ @@ -373,6 +375,13 @@ India (``in_``) A ``Select`` widget that uses a list of Indian states/territories as its choices. +Ireland (``ie``) +================ + +.. class:: ie.forms.IECountySelect + + A ``Select`` widget that uses a list of Irish Counties as its choices. + Italy (``it``) ============== diff --git a/tests/regressiontests/forms/localflavor/ie.py b/tests/regressiontests/forms/localflavor/ie.py new file mode 100644 index 00000000000..540281c19e7 --- /dev/null +++ b/tests/regressiontests/forms/localflavor/ie.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Tests for the contrib/localflavor/ie form fields. + +tests = r""" +# IECountySelect ######################################################### + +>>> from django.contrib.localflavor.ie.forms import IECountySelect +>>> f = IECountySelect() +>>> f.render('counties', 'dublin') +u'' + +""" diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index bc30e3c82e2..e246d7290c5 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -15,6 +15,7 @@ from localflavor.es import tests as localflavor_es_tests from localflavor.fi import tests as localflavor_fi_tests from localflavor.fr import tests as localflavor_fr_tests from localflavor.generic import tests as localflavor_generic_tests +from localflavor.ie import tests as localflavor_ie_tests from localflavor.is_ import tests as localflavor_is_tests from localflavor.it import tests as localflavor_it_tests from localflavor.jp import tests as localflavor_jp_tests @@ -53,6 +54,7 @@ __test__ = { 'localflavor_fi_tests': localflavor_fi_tests, 'localflavor_fr_tests': localflavor_fr_tests, 'localflavor_generic_tests': localflavor_generic_tests, + 'localflavor_ie_tests': localflavor_ie_tests, 'localflavor_is_tests': localflavor_is_tests, 'localflavor_it_tests': localflavor_it_tests, 'localflavor_jp_tests': localflavor_jp_tests,