Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #11123 - Added Irish (ie) localflavor.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12043 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6eb205c91447ce8237f0919e156b7d26f6ffc1cd 1 parent 82b33b1
@jezdez jezdez authored
View
0  django/contrib/localflavor/ie/__init__.py
No changes.
View
13 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)
View
40 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')),
+)
View
9 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``)
==============
View
12 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'<select name="counties">\n<option value="antrim">Antrim</option>\n<option value="armagh">Armagh</option>\n<option value="carlow">Carlow</option>\n<option value="cavan">Cavan</option>\n<option value="clare">Clare</option>\n<option value="cork">Cork</option>\n<option value="derry">Derry</option>\n<option value="donegal">Donegal</option>\n<option value="down">Down</option>\n<option value="dublin" selected="selected">Dublin</option>\n<option value="fermanagh">Fermanagh</option>\n<option value="galway">Galway</option>\n<option value="kerry">Kerry</option>\n<option value="kildare">Kildare</option>\n<option value="kilkenny">Kilkenny</option>\n<option value="laois">Laois</option>\n<option value="leitrim">Leitrim</option>\n<option value="limerick">Limerick</option>\n<option value="longford">Longford</option>\n<option value="louth">Louth</option>\n<option value="mayo">Mayo</option>\n<option value="meath">Meath</option>\n<option value="monaghan">Monaghan</option>\n<option value="offaly">Offaly</option>\n<option value="roscommon">Roscommon</option>\n<option value="sligo">Sligo</option>\n<option value="tipperary">Tipperary</option>\n<option value="tyrone">Tyrone</option>\n<option value="waterford">Waterford</option>\n<option value="westmeath">Westmeath</option>\n<option value="wexford">Wexford</option>\n<option value="wicklow">Wicklow</option>\n</select>'
+
+"""
View
2  tests/regressiontests/forms/tests.py
@@ -15,6 +15,7 @@
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 @@
'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,
Please sign in to comment.
Something went wrong with that request. Please try again.