Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f31754
commit 612a6da
Showing
6 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
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,17 @@ | ||
""" http://www.bitboost.com/ref/international-address-formats.html """ | ||
from django import forms | ||
from django.utils.translation import ugettext_lazy as _ | ||
from django.contrib.localflavor.ar.forms import ARProvinceSelect, ARPostalCodeField | ||
|
||
from postal.forms import PostalAddressForm | ||
|
||
class ARPostalAddressForm(PostalAddressForm): | ||
line1 = forms.CharField(label=_(u"Street"), max_length=50) | ||
line2 = forms.CharField(label=_(u"Number"), max_length=50) | ||
city = forms.CharField(label=_(u"City"), max_length=50) | ||
state = forms.CharField(label=_(u"Province"), widget=ARProvinceSelect) | ||
code = ARPostalCodeField(label=_(u"Zip Code")) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(ARPostalAddressForm, self).__init__(*args, **kwargs) | ||
self.fields['country'].initial = "AR" |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
from test_l10n import * | ||
from test_l10n import * | ||
from test_widgets import * |
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,35 @@ | ||
from django.test import TestCase | ||
from django.utils.translation import ugettext | ||
from django import forms | ||
|
||
from postal.library import form_factory | ||
import postal.settings | ||
import postal.forms | ||
|
||
|
||
class PostalWidgetsTests(TestCase): | ||
def test_environment(self): | ||
"""Just make sure everything is set up correctly.""" | ||
self.assert_(True) | ||
|
||
def test_ar_widgets(self): | ||
""" | ||
Tests that we get the correct widget for Argentina | ||
""" | ||
form_class = form_factory("ar") | ||
self.assertNotEqual(form_class, None) | ||
|
||
# only use required fields | ||
test_data = { | ||
'line1': 'Maipu', | ||
'line2': '270', | ||
'city': 'Ciudad de Buenos Aires', | ||
'state': 'B', | ||
'code': 'C1006ACT', | ||
} | ||
form = form_class(data=test_data) | ||
|
||
from django.contrib.localflavor.ar.forms import ARProvinceSelect, ARPostalCodeField | ||
self.assertIsInstance(form.fields['state'].widget, ARProvinceSelect) | ||
self.assertIsInstance(form.fields['code'], ARPostalCodeField) | ||
self.assertEqual(form.fields['country'].initial, 'AR') |