From 1245b5c01ed4e9716ceda1e14e1167a70093a3b5 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sun, 8 Apr 2007 11:21:00 +0000 Subject: Backwards-incompatible change -- Renamed localflavor.usa to localflavor.us to match naming of other flavors. git-svn-id: http://code.djangoproject.com/svn/django/trunk@4954 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/localflavor/us/__init__.py | 0 django/contrib/localflavor/us/forms.py | 99 ++++++++++++ django/contrib/localflavor/us/us_states.py | 239 ++++++++++++++++++++++++++++ django/contrib/localflavor/usa/__init__.py | 0 django/contrib/localflavor/usa/forms.py | 99 ------------ django/contrib/localflavor/usa/us_states.py | 239 ---------------------------- django/db/models/fields/__init__.py | 2 +- tests/regressiontests/forms/localflavor.py | 10 +- 8 files changed, 344 insertions(+), 344 deletions(-) create mode 100644 django/contrib/localflavor/us/__init__.py create mode 100644 django/contrib/localflavor/us/forms.py create mode 100644 django/contrib/localflavor/us/us_states.py delete mode 100644 django/contrib/localflavor/usa/__init__.py delete mode 100644 django/contrib/localflavor/usa/forms.py delete mode 100644 django/contrib/localflavor/usa/us_states.py diff --git a/django/contrib/localflavor/us/__init__.py b/django/contrib/localflavor/us/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/django/contrib/localflavor/us/forms.py b/django/contrib/localflavor/us/forms.py new file mode 100644 index 0000000000..feda68291b --- /dev/null +++ b/django/contrib/localflavor/us/forms.py @@ -0,0 +1,99 @@ +""" +USA-specific Form helpers +""" + +from django.newforms import ValidationError +from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES +from django.utils.encoding import smart_unicode +from django.utils.translation import gettext +import re + +phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$') +ssn_re = re.compile(r"^(?P\d{3})[-\ ]?(?P\d{2})[-\ ]?(?P\d{4})$") + +class USZipCodeField(RegexField): + def __init__(self, *args, **kwargs): + super(USZipCodeField, self).__init__(r'^\d{5}(?:-\d{4})?$', + max_length=None, min_length=None, + error_message=gettext(u'Enter a zip code in the format XXXXX or XXXXX-XXXX.'), + *args, **kwargs) + +class USPhoneNumberField(Field): + def clean(self, value): + super(USPhoneNumberField, self).clean(value) + if value in EMPTY_VALUES: + return u'' + value = re.sub('(\(|\)|\s+)', '', smart_unicode(value)) + m = phone_digits_re.search(value) + if m: + return u'%s-%s-%s' % (m.group(1), m.group(2), m.group(3)) + raise ValidationError(u'Phone numbers must be in XXX-XXX-XXXX format.') + +class USSocialSecurityNumberField(Field): + """ + A United States Social Security number. + + Checks the following rules to determine whether the number is valid: + + * Conforms to the XXX-XX-XXXX format. + * No group consists entirely of zeroes. + * The leading group is not "666" (block "666" will never be allocated). + * The number is not in the promotional block 987-65-4320 through 987-65-4329, + which are permanently invalid. + * The number is not one known to be invalid due to otherwise widespread + promotional use or distribution (e.g., the Woolworth's number or the 1962 + promotional number). + """ + def clean(self, value): + super(USSocialSecurityNumberField, self).clean(value) + if value in EMPTY_VALUES: + return u'' + msg = gettext(u'Enter a valid U.S. Social Security number in XXX-XX-XXXX format.') + match = re.match(ssn_re, value) + if not match: + raise ValidationError(msg) + area, group, serial = match.groupdict()['area'], match.groupdict()['group'], match.groupdict()['serial'] + + # First pass: no blocks of all zeroes. + if area == '000' or \ + group == '00' or \ + serial == '0000': + raise ValidationError(msg) + + # Second pass: promotional and otherwise permanently invalid numbers. + if area == '666' or \ + (area == '987' and group == '65' and 4320 <= int(serial) <= 4329) or \ + value == '078-05-1120' or \ + value == '219-09-9999': + raise ValidationError(msg) + return u'%s-%s-%s' % (area, group, serial) + +class USStateField(Field): + """ + A form field that validates its input is a U.S. state name or abbreviation. + It normalizes the input to the standard two-leter postal service + abbreviation for the given state. + """ + def clean(self, value): + from us_states import STATES_NORMALIZED # relative import + super(USStateField, self).clean(value) + if value in EMPTY_VALUES: + return u'' + try: + value = value.strip().lower() + except AttributeError: + pass + else: + try: + return STATES_NORMALIZED[value.strip().lower()].decode('ascii') + except KeyError: + pass + raise ValidationError(u'Enter a U.S. state or territory.') + +class USStateSelect(Select): + """ + A Select widget that uses a list of U.S. states/territories as its choices. + """ + def __init__(self, attrs=None): + from us_states import STATE_CHOICES # relative import + super(USStateSelect, self).__init__(attrs, choices=STATE_CHOICES) diff --git a/django/contrib/localflavor/us/us_states.py b/django/contrib/localflavor/us/us_states.py new file mode 100644 index 0000000000..89124a4b69 --- /dev/null +++ b/django/contrib/localflavor/us/us_states.py @@ -0,0 +1,239 @@ +""" +A mapping of state misspellings/abbreviations to normalized abbreviations, and +an alphabetical list of states for use as `choices` in a formfield. + +This exists in this standalone file so that it's only imported into memory +when explicitly needed. +""" + +STATE_CHOICES = ( + ('AL', 'Alabama'), + ('AK', 'Alaska'), + ('AS', 'American Samoa'), + ('AZ', 'Arizona'), + ('AR', 'Arkansas'), + ('CA', 'California'), + ('CO', 'Colorado'), + ('CT', 'Connecticut'), + ('DE', 'Deleware'), + ('DC', 'District of Columbia'), + ('FM', 'Federated States of Micronesia'), + ('FL', 'Florida'), + ('GA', 'Georgia'), + ('GU', 'Guam'), + ('HI', 'Hawaii'), + ('ID', 'Idaho'), + ('IL', 'Illinois'), + ('IN', 'Indiana'), + ('IA', 'Iowa'), + ('KS', 'Kansas'), + ('KY', 'Kentucky'), + ('LA', 'Louisiana'), + ('ME', 'Maine'), + ('MH', 'Marshall Islands'), + ('MD', 'Maryland'), + ('MA', 'Massachusetts'), + ('MI', 'Michigan'), + ('MN', 'Minnesota'), + ('MS', 'Mississippi'), + ('MO', 'Missouri'), + ('MT', 'Montana'), + ('NE', 'Nebraska'), + ('NV', 'Nevada'), + ('NH', 'New Hampshire'), + ('NJ', 'New Jersey'), + ('NM', 'New Mexico'), + ('NY', 'New York'), + ('NC', 'North Carolina'), + ('ND', 'North Dakota'), + ('MP', 'Northern Mariana Islands'), + ('OH', 'Ohio'), + ('OK', 'Oklahoma'), + ('OR', 'Oregon'), + ('PW', 'Palau'), + ('PA', 'Pennsylvania'), + ('PR', 'Puerto Rico'), + ('RI', 'Rhode Island'), + ('SC', 'South Carolina'), + ('SD', 'South Dakota'), + ('TN', 'Tennessee'), + ('TX', 'Texas'), + ('UT', 'Utah'), + ('VT', 'Vermont'), + ('VI', 'Virgin Islands'), + ('VA', 'Virginia'), + ('WA', 'Washington'), + ('WV', 'West Virginia'), + ('WI', 'Wisconsin'), + ('WY', 'Wyoming'), +) + +STATES_NORMALIZED = { + 'ak': 'AK', + 'al': 'AL', + 'ala': 'AL', + 'alabama': 'AL', + 'alaska': 'AK', + 'american samao': 'AS', + 'american samoa': 'AS', + 'ar': 'AR', + 'ariz': 'AZ', + 'arizona': 'AZ', + 'ark': 'AR', + 'arkansas': 'AR', + 'as': 'AS', + 'az': 'AZ', + 'ca': 'CA', + 'calf': 'CA', + 'calif': 'CA', + 'california': 'CA', + 'co': 'CO', + 'colo': 'CO', + 'colorado': 'CO', + 'conn': 'CT', + 'connecticut': 'CT', + 'ct': 'CT', + 'dc': 'DC', + 'de': 'DE', + 'del': 'DE', + 'delaware': 'DE', + 'district of columbia': 'DC', + 'federated states of micronesia': 'FM', + 'fl': 'FL', + 'fla': 'FL', + 'florida': 'FL', + 'fm': 'FM', + 'ga': 'GA', + 'georgia': 'GA', + 'gu': 'GU', + 'guam': 'GU', + 'hawaii': 'HI', + 'hi': 'HI', + 'ia': 'IA', + 'id': 'ID', + 'idaho': 'ID', + 'il': 'IL', + 'ill': 'IL', + 'illinois': 'IL', + 'in': 'IN', + 'ind': 'IN', + 'indiana': 'IN', + 'iowa': 'IA', + 'kan': 'KS', + 'kans': 'KS', + 'kansas': 'KS', + 'kentucky': 'KY', + 'ks': 'KS', + 'ky': 'KY', + 'la': 'LA', + 'louisiana': 'LA', + 'ma': 'MA', + 'maine': 'ME', + 'marianas islands': 'MP', + 'marianas islands of the pacific': 'MP', + 'marinas islands of the pacific': 'MP', + 'maryland': 'MD', + 'mass': 'MA', + 'massachusetts': 'MA', + 'massachussetts': 'MA', + 'md': 'MD', + 'me': 'ME', + 'mi': 'MI', + 'mich': 'MI', + 'michigan': 'MI', + 'micronesia': 'FM', + 'minn': 'MN', + 'minnesota': 'MN', + 'miss': 'MS', + 'mississippi': 'MS', + 'missouri': 'MO', + 'mn': 'MN', + 'mo': 'MO', + 'mont': 'MT', + 'montana': 'MT', + 'mp': 'MP', + 'ms': 'MS', + 'mt': 'MT', + 'n d': 'ND', + 'n dak': 'ND', + 'n h': 'NH', + 'n j': 'NJ', + 'n m': 'NM', + 'n mex': 'NM', + 'nc': 'NC', + 'nd': 'ND', + 'ne': 'NE', + 'neb': 'NE', + 'nebr': 'NE', + 'nebraska': 'NE', + 'nev': 'NV', + 'nevada': 'NV', + 'new hampshire': 'NH', + 'new jersey': 'NJ', + 'new mexico': 'NM', + 'new york': 'NY', + 'nh': 'NH', + 'nj': 'NJ', + 'nm': 'NM', + 'nmex': 'NM', + 'north carolina': 'NC', + 'north dakota': 'ND', + 'northern mariana islands': 'MP', + 'nv': 'NV', + 'ny': 'NY', + 'oh': 'OH', + 'ohio': 'OH', + 'ok': 'OK', + 'okla': 'OK', + 'oklahoma': 'OK', + 'or': 'OR', + 'ore': 'OR', + 'oreg': 'OR', + 'oregon': 'OR', + 'pa': 'PA', + 'penn': 'PA', + 'pennsylvania': 'PA', + 'pr': 'PR', + 'puerto rico': 'PR', + 'rhode island': 'RI', + 'ri': 'RI', + 's dak': 'SD', + 'sc': 'SC', + 'sd': 'SD', + 'sdak': 'SD', + 'south carolina': 'SC', + 'south dakota': 'SD', + 'tenn': 'TN', + 'tennessee': 'TN', + 'territory of hawaii': 'HI', + 'tex': 'TX', + 'texas': 'TX', + 'tn': 'TN', + 'tx': 'TX', + 'us virgin islands': 'VI', + 'usvi': 'VI', + 'ut': 'UT', + 'utah': 'UT', + 'va': 'VA', + 'vermont': 'VT', + 'vi': 'VI', + 'viginia': 'VA', + 'virgin islands': 'VI', + 'virgina': 'VA', + 'virginia': 'VA', + 'vt': 'VT', + 'w va': 'WV', + 'wa': 'WA', + 'wash': 'WA', + 'washington': 'WA', + 'west virginia': 'WV', + 'wi': 'WI', + 'wis': 'WI', + 'wisc': 'WI', + 'wisconsin': 'WI', + 'wv': 'WV', + 'wva': 'WV', + 'wy': 'WY', + 'wyo': 'WY', + 'wyoming': 'WY', +} diff --git a/django/contrib/localflavor/usa/__init__.py b/django/contrib/localflavor/usa/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/django/contrib/localflavor/usa/forms.py b/django/contrib/localflavor/usa/forms.py deleted file mode 100644 index feda68291b..0000000000 --- a/django/contrib/localflavor/usa/forms.py +++ /dev/null @@ -1,99 +0,0 @@ -""" -USA-specific Form helpers -""" - -from django.newforms import ValidationError -from django.newforms.fields import Field, RegexField, Select, EMPTY_VALUES -from django.utils.encoding import smart_unicode -from django.utils.translation import gettext -import re - -phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$') -ssn_re = re.compile(r"^(?P\d{3})[-\ ]?(?P\d{2})[-\ ]?(?P\d{4})$") - -class USZipCodeField(RegexField): - def __init__(self, *args, **kwargs): - super(USZipCodeField, self).__init__(r'^\d{5}(?:-\d{4})?$', - max_length=None, min_length=None, - error_message=gettext(u'Enter a zip code in the format XXXXX or XXXXX-XXXX.'), - *args, **kwargs) - -class USPhoneNumberField(Field): - def clean(self, value): - super(USPhoneNumberField, self).clean(value) - if value in EMPTY_VALUES: - return u'' - value = re.sub('(\(|\)|\s+)', '', smart_unicode(value)) - m = phone_digits_re.search(value) - if m: - return u'%s-%s-%s' % (m.group(1), m.group(2), m.group(3)) - raise ValidationError(u'Phone numbers must be in XXX-XXX-XXXX format.') - -class USSocialSecurityNumberField(Field): - """ - A United States Social Security number. - - Checks the following rules to determine whether the number is valid: - - * Conforms to the XXX-XX-XXXX format. - * No group consists entirely of zeroes. - * The leading group is not "666" (block "666" will never be allocated). - * The number is not in the promotional block 987-65-4320 through 987-65-4329, - which are permanently invalid. - * The number is not one known to be invalid due to otherwise widespread - promotional use or distribution (e.g., the Woolworth's number or the 1962 - promotional number). - """ - def clean(self, value): - super(USSocialSecurityNumberField, self).clean(value) - if value in EMPTY_VALUES: - return u'' - msg = gettext(u'Enter a valid U.S. Social Security number in XXX-XX-XXXX format.') - match = re.match(ssn_re, value) - if not match: - raise ValidationError(msg) - area, group, serial = match.groupdict()['area'], match.groupdict()['group'], match.groupdict()['serial'] - - # First pass: no blocks of all zeroes. - if area == '000' or \ - group == '00' or \ - serial == '0000': - raise ValidationError(msg) - - # Second pass: promotional and otherwise permanently invalid numbers. - if area == '666' or \ - (area == '987' and group == '65' and 4320 <= int(serial) <= 4329) or \ - value == '078-05-1120' or \ - value == '219-09-9999': - raise ValidationError(msg) - return u'%s-%s-%s' % (area, group, serial) - -class USStateField(Field): - """ - A form field that validates its input is a U.S. state name or abbreviation. - It normalizes the input to the standard two-leter postal service - abbreviation for the given state. - """ - def clean(self, value): - from us_states import STATES_NORMALIZED # relative import - super(USStateField, self).clean(value) - if value in EMPTY_VALUES: - return u'' - try: - value = value.strip().lower() - except AttributeError: - pass - else: - try: - return STATES_NORMALIZED[value.strip().lower()].decode('ascii') - except KeyError: - pass - raise ValidationError(u'Enter a U.S. state or territory.') - -class USStateSelect(Select): - """ - A Select widget that uses a list of U.S. states/territories as its choices. - """ - def __init__(self, attrs=None): - from us_states import STATE_CHOICES # relative import - super(USStateSelect, self).__init__(attrs, choices=STATE_CHOICES) diff --git a/django/contrib/localflavor/usa/us_states.py b/django/contrib/localflavor/usa/us_states.py deleted file mode 100644 index 89124a4b69..0000000000 --- a/django/contrib/localflavor/usa/us_states.py +++ /dev/null @@ -1,239 +0,0 @@ -""" -A mapping of state misspellings/abbreviations to normalized abbreviations, and -an alphabetical list of states for use as `choices` in a formfield. - -This exists in this standalone file so that it's only imported into memory -when explicitly needed. -""" - -STATE_CHOICES = ( - ('AL', 'Alabama'), - ('AK', 'Alaska'), - ('AS', 'American Samoa'), - ('AZ', 'Arizona'), - ('AR', 'Arkansas'), - ('CA', 'California'), - ('CO', 'Colorado'), - ('CT', 'Connecticut'), - ('DE', 'Deleware'), - ('DC', 'District of Columbia'), - ('FM', 'Federated States of Micronesia'), - ('FL', 'Florida'), - ('GA', 'Georgia'), - ('GU', 'Guam'), - ('HI', 'Hawaii'), - ('ID', 'Idaho'), - ('IL', 'Illinois'), - ('IN', 'Indiana'), - ('IA', 'Iowa'), - ('KS', 'Kansas'), - ('KY', 'Kentucky'), - ('LA', 'Louisiana'), - ('ME', 'Maine'), - ('MH', 'Marshall Islands'), - ('MD', 'Maryland'), - ('MA', 'Massachusetts'), - ('MI', 'Michigan'), - ('MN', 'Minnesota'), - ('MS', 'Mississippi'), - ('MO', 'Missouri'), - ('MT', 'Montana'), - ('NE', 'Nebraska'), - ('NV', 'Nevada'), - ('NH', 'New Hampshire'), - ('NJ', 'New Jersey'), - ('NM', 'New Mexico'), - ('NY', 'New York'), - ('NC', 'North Carolina'), - ('ND', 'North Dakota'), - ('MP', 'Northern Mariana Islands'), - ('OH', 'Ohio'), - ('OK', 'Oklahoma'), - ('OR', 'Oregon'), - ('PW', 'Palau'), - ('PA', 'Pennsylvania'), - ('PR', 'Puerto Rico'), - ('RI', 'Rhode Island'), - ('SC', 'South Carolina'), - ('SD', 'South Dakota'), - ('TN', 'Tennessee'), - ('TX', 'Texas'), - ('UT', 'Utah'), - ('VT', 'Vermont'), - ('VI', 'Virgin Islands'), - ('VA', 'Virginia'), - ('WA', 'Washington'), - ('WV', 'West Virginia'), - ('WI', 'Wisconsin'), - ('WY', 'Wyoming'), -) - -STATES_NORMALIZED = { - 'ak': 'AK', - 'al': 'AL', - 'ala': 'AL', - 'alabama': 'AL', - 'alaska': 'AK', - 'american samao': 'AS', - 'american samoa': 'AS', - 'ar': 'AR', - 'ariz': 'AZ', - 'arizona': 'AZ', - 'ark': 'AR', - 'arkansas': 'AR', - 'as': 'AS', - 'az': 'AZ', - 'ca': 'CA', - 'calf': 'CA', - 'calif': 'CA', - 'california': 'CA', - 'co': 'CO', - 'colo': 'CO', - 'colorado': 'CO', - 'conn': 'CT', - 'connecticut': 'CT', - 'ct': 'CT', - 'dc': 'DC', - 'de': 'DE', - 'del': 'DE', - 'delaware': 'DE', - 'district of columbia': 'DC', - 'federated states of micronesia': 'FM', - 'fl': 'FL', - 'fla': 'FL', - 'florida': 'FL', - 'fm': 'FM', - 'ga': 'GA', - 'georgia': 'GA', - 'gu': 'GU', - 'guam': 'GU', - 'hawaii': 'HI', - 'hi': 'HI', - 'ia': 'IA', - 'id': 'ID', - 'idaho': 'ID', - 'il': 'IL', - 'ill': 'IL', - 'illinois': 'IL', - 'in': 'IN', - 'ind': 'IN', - 'indiana': 'IN', - 'iowa': 'IA', - 'kan': 'KS', - 'kans': 'KS', - 'kansas': 'KS', - 'kentucky': 'KY', - 'ks': 'KS', - 'ky': 'KY', - 'la': 'LA', - 'louisiana': 'LA', - 'ma': 'MA', - 'maine': 'ME', - 'marianas islands': 'MP', - 'marianas islands of the pacific': 'MP', - 'marinas islands of the pacific': 'MP', - 'maryland': 'MD', - 'mass': 'MA', - 'massachusetts': 'MA', - 'massachussetts': 'MA', - 'md': 'MD', - 'me': 'ME', - 'mi': 'MI', - 'mich': 'MI', - 'michigan': 'MI', - 'micronesia': 'FM', - 'minn': 'MN', - 'minnesota': 'MN', - 'miss': 'MS', - 'mississippi': 'MS', - 'missouri': 'MO', - 'mn': 'MN', - 'mo': 'MO', - 'mont': 'MT', - 'montana': 'MT', - 'mp': 'MP', - 'ms': 'MS', - 'mt': 'MT', - 'n d': 'ND', - 'n dak': 'ND', - 'n h': 'NH', - 'n j': 'NJ', - 'n m': 'NM', - 'n mex': 'NM', - 'nc': 'NC', - 'nd': 'ND', - 'ne': 'NE', - 'neb': 'NE', - 'nebr': 'NE', - 'nebraska': 'NE', - 'nev': 'NV', - 'nevada': 'NV', - 'new hampshire': 'NH', - 'new jersey': 'NJ', - 'new mexico': 'NM', - 'new york': 'NY', - 'nh': 'NH', - 'nj': 'NJ', - 'nm': 'NM', - 'nmex': 'NM', - 'north carolina': 'NC', - 'north dakota': 'ND', - 'northern mariana islands': 'MP', - 'nv': 'NV', - 'ny': 'NY', - 'oh': 'OH', - 'ohio': 'OH', - 'ok': 'OK', - 'okla': 'OK', - 'oklahoma': 'OK', - 'or': 'OR', - 'ore': 'OR', - 'oreg': 'OR', - 'oregon': 'OR', - 'pa': 'PA', - 'penn': 'PA', - 'pennsylvania': 'PA', - 'pr': 'PR', - 'puerto rico': 'PR', - 'rhode island': 'RI', - 'ri': 'RI', - 's dak': 'SD', - 'sc': 'SC', - 'sd': 'SD', - 'sdak': 'SD', - 'south carolina': 'SC', - 'south dakota': 'SD', - 'tenn': 'TN', - 'tennessee': 'TN', - 'territory of hawaii': 'HI', - 'tex': 'TX', - 'texas': 'TX', - 'tn': 'TN', - 'tx': 'TX', - 'us virgin islands': 'VI', - 'usvi': 'VI', - 'ut': 'UT', - 'utah': 'UT', - 'va': 'VA', - 'vermont': 'VT', - 'vi': 'VI', - 'viginia': 'VA', - 'virgin islands': 'VI', - 'virgina': 'VA', - 'virginia': 'VA', - 'vt': 'VT', - 'w va': 'WV', - 'wa': 'WA', - 'wash': 'WA', - 'washington': 'WA', - 'west virginia': 'WV', - 'wi': 'WI', - 'wis': 'WI', - 'wisc': 'WI', - 'wisconsin': 'WI', - 'wv': 'WV', - 'wva': 'WV', - 'wy': 'WY', - 'wyo': 'WY', - 'wyoming': 'WY', -} diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 3972de7d4a..466897ad86 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -761,7 +761,7 @@ class PhoneNumberField(IntegerField): validators.isValidPhone(field_data, all_data) def formfield(self, **kwargs): - from django.contrib.localflavor.usa.forms import USPhoneNumberField + from django.contrib.localflavor.us.forms import USPhoneNumberField defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} defaults.update(kwargs) return USPhoneNumberField(**defaults) diff --git a/tests/regressiontests/forms/localflavor.py b/tests/regressiontests/forms/localflavor.py index fecb57d81b..5c6f610b16 100644 --- a/tests/regressiontests/forms/localflavor.py +++ b/tests/regressiontests/forms/localflavor.py @@ -6,7 +6,7 @@ localflavor_tests = r""" USZipCodeField validates that the data is either a five-digit U.S. zip code or a zip+4. ->>> from django.contrib.localflavor.usa.forms import USZipCodeField +>>> from django.contrib.localflavor.us.forms import USZipCodeField >>> f = USZipCodeField() >>> f.clean('60606') u'60606' @@ -67,7 +67,7 @@ u'' USPhoneNumberField validates that the data is a valid U.S. phone number, including the area code. It's normalized to XXX-XXX-XXXX format. ->>> from django.contrib.localflavor.usa.forms import USPhoneNumberField +>>> from django.contrib.localflavor.us.forms import USPhoneNumberField >>> f = USPhoneNumberField() >>> f.clean('312-555-1212') u'312-555-1212' @@ -136,7 +136,7 @@ u'' USStateField validates that the data is either an abbreviation or name of a U.S. state. ->>> from django.contrib.localflavor.usa.forms import USStateField +>>> from django.contrib.localflavor.us.forms import USStateField >>> f = USStateField() >>> f.clean('il') u'IL' @@ -181,7 +181,7 @@ u'' USStateSelect is a Select widget that uses a list of U.S. states/territories as its choices. ->>> from django.contrib.localflavor.usa.forms import USStateSelect +>>> from django.contrib.localflavor.us.forms import USStateSelect >>> w = USStateSelect() >>> print w.render('state', 'IL') # USSocialSecurityNumberField ################################################# ->>> from django.contrib.localflavor.usa.forms import USSocialSecurityNumberField +>>> from django.contrib.localflavor.us.forms import USSocialSecurityNumberField >>> f = USSocialSecurityNumberField() >>> f.clean('987-65-4330') u'987-65-4330' -- cgit v1.3