-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Hungarian Counties select widget
- Loading branch information
Showing
8 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Hungary (``hu``) | ||
================ | ||
|
||
Forms | ||
----- | ||
|
||
.. automodule:: localflavor.hu.forms | ||
:members: | ||
|
||
Data | ||
---- | ||
|
||
.. autodata:: localflavor.hu.hu_counties.HU_COUNTY_CHOICES |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""HU-specific Form helpers""" | ||
|
||
from django.forms.fields import Select | ||
|
||
from .hu_counties import HU_COUNTY_CHOICES | ||
|
||
|
||
class HUCountySelect(Select): | ||
""" | ||
A Select widget that uses a list of Hungarian Counties as its choices. | ||
.. versionadded:: 1.3 | ||
""" | ||
|
||
def __init__(self, attrs=None): | ||
super(HUCountySelect, self).__init__(attrs, choices=HU_COUNTY_CHOICES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
#: Hungarian counties: https://en.wikipedia.org/wiki/Counties_of_Hungary | ||
HU_COUNTY_CHOICES = ( | ||
('bacs_kiskun', _('Bács-Kiskun')), | ||
('baranya', _('Baranya')), | ||
('bekes', _('Békés')), | ||
('borsod_abauj_zemplen', _('Borsod-Abaúj-Zemplén')), | ||
('csongrad', _('Csongrád')), | ||
('fejer', _('Fejér')), | ||
('gyor_moson_sopron', _('Győr-Moson-Sopron')), | ||
('hajdu_bihar', _('Hajdú-Bihar')), | ||
('heves', _('Heves')), | ||
('jasz_nagykun_szolnok', _('Jász-Nagykun-Szolnok')), | ||
('komarom_esztergom', _('Komárom-Esztergom')), | ||
('nograd', _('Nógrád')), | ||
('pest', _('Pest')), | ||
('somogy', _('Somogy')), | ||
('szabolcs_szatmar_bereg', _('Szabolcs-Szatmár-Bereg')), | ||
('tolna', _('Tolna')), | ||
('vas', _('Vas')), | ||
('veszprem', _('Veszprém')), | ||
('zala', _('Zala')), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.test import SimpleTestCase | ||
|
||
from localflavor.hu.forms import HUCountySelect | ||
|
||
|
||
class HULocalFlavorTests(SimpleTestCase): | ||
def test_HUCountySelect(self): | ||
f = HUCountySelect() | ||
out = '''<select name="counties"> | ||
<option value="bacs_kiskun">Bács-Kiskun</option> | ||
<option value="baranya">Baranya</option> | ||
<option value="bekes">Békés</option> | ||
<option value="borsod_abauj_zemplen">Borsod-Abaúj-Zemplén</option> | ||
<option value="csongrad">Csongrád</option> | ||
<option value="fejer">Fejér</option> | ||
<option value="gyor_moson_sopron">Győr-Moson-Sopron</option> | ||
<option value="hajdu_bihar">Hajdú-Bihar</option> | ||
<option value="heves">Heves</option> | ||
<option value="jasz_nagykun_szolnok">Jász-Nagykun-Szolnok</option> | ||
<option value="komarom_esztergom">Komárom-Esztergom</option> | ||
<option value="nograd">Nógrád</option> | ||
<option value="pest">Pest</option> | ||
<option value="somogy">Somogy</option> | ||
<option value="szabolcs_szatmar_bereg">Szabolcs-Szatmár-Bereg</option> | ||
<option value="tolna">Tolna</option> | ||
<option value="vas" selected="selected">Vas</option> | ||
<option value="veszprem">Veszprém</option> | ||
<option value="zala">Zala</option> | ||
</select>''' | ||
self.assertHTMLEqual(f.render('counties', 'vas'), out) |