From e5fb29140b8bc27909552e83b6b7ef3b36c80f12 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sun, 12 Aug 2007 01:19:54 +0000 Subject: Moved in_ directory to its correct location under localflavor. I committed it in the wrong place in [5847]. Fixed #3986. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5856 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/in_/__init__.py | 1 - django/contrib/in_/forms.py | 49 ----------------- django/contrib/in_/in_states.py | 84 ----------------------------- django/contrib/localflavor/in_/__init__.py | 0 django/contrib/localflavor/in_/forms.py | 49 +++++++++++++++++ django/contrib/localflavor/in_/in_states.py | 84 +++++++++++++++++++++++++++++ 6 files changed, 133 insertions(+), 134 deletions(-) delete mode 100644 django/contrib/in_/__init__.py delete mode 100644 django/contrib/in_/forms.py delete mode 100644 django/contrib/in_/in_states.py create mode 100644 django/contrib/localflavor/in_/__init__.py create mode 100644 django/contrib/localflavor/in_/forms.py create mode 100644 django/contrib/localflavor/in_/in_states.py diff --git a/django/contrib/in_/__init__.py b/django/contrib/in_/__init__.py deleted file mode 100644 index 143f486c05..0000000000 --- a/django/contrib/in_/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# __init__.py diff --git a/django/contrib/in_/forms.py b/django/contrib/in_/forms.py deleted file mode 100644 index 5febc40e67..0000000000 --- a/django/contrib/in_/forms.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -India-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 - - -class INZipCodeField(RegexField): - def __init__(self, *args, **kwargs): - super(INZipCodeField, self).__init__(r'^\d{6}$', - max_length=None, min_length=None, - error_message=gettext(u'Enter a zip code in the format XXXXXXX.'), - *args, **kwargs) - -class INStateField(Field): - """ - A form field that validates its input is a Indian state name or - abbreviation. It normalizes the input to the standard two-letter vehicle - registration abbreviation for the given state or union territory - """ - def clean(self, value): - from in_states import STATES_NORMALIZED - super(INStateField, self).clean(value) - if value in EMPTY_VALUES: - return u'' - try: - value = value.strip().lower() - except AttributeError: - pass - else: - try: - return smart_unicode(STATES_NORMALIZED[value.strip().lower()]) - except KeyError: - pass - raise ValidationError(u'Enter a Indian state or territory.') - -class INStateSelect(Select): - """ - A Select widget that uses a list of Indian states/territories as its - choices. - """ - def __init__(self, attrs=None): - from in_states import STATE_CHOICES - super(INStateSelect, self).__init__(attrs, choices=STATE_CHOICES) - diff --git a/django/contrib/in_/in_states.py b/django/contrib/in_/in_states.py deleted file mode 100644 index faa3a9101b..0000000000 --- a/django/contrib/in_/in_states.py +++ /dev/null @@ -1,84 +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 = ( - 'KA', 'Karnataka', - 'AP', 'Andhra Pradesh', - 'KL', 'Kerala', - 'TN', 'Tamil Nadu', - 'MH', 'Maharashtra', - 'UP', 'Uttar Pradesh', - 'GA', 'Goa', - 'GJ', 'Gujarat', - 'RJ', 'Rajasthan', - 'HP', 'Himachal Pradesh', - 'JK', 'Jammu and Kashmir', - 'AR', 'Arunachal Pradesh', - 'AS', 'Assam', - 'BR', 'Bihar', - 'CG', 'Chattisgarh', - 'HR', 'Haryana', - 'JH', 'Jharkhand', - 'MP', 'Madhya Pradesh', - 'MN', 'Manipur', - 'ML', 'Meghalaya', - 'MZ', 'Mizoram', - 'NL', 'Nagaland', - 'OR', 'Orissa', - 'PB', 'Punjab', - 'SK', 'Sikkim', - 'TR', 'Tripura', - 'UA', 'Uttarakhand', - 'WB', 'West Bengal', - #Union Territories - 'AN', 'Andaman and Nicobar', - 'CH', 'Chandigarh', - 'DN', 'Dadra and Nagar Haveli', - 'DD', 'Daman and Diu', - 'DL', 'Delhi', - 'LD', 'Lakshadweep', - 'PY', 'Pondicherry', -) - -STATES_NORMALIZED = { - 'ka': 'KA', - 'karnatka': 'KA', - 'tn': 'TN', - 'tamilnad': 'TN', - 'tamilnadu': 'TN', - 'andra pradesh': 'AP', - 'andrapradesh': 'AP', - 'andhrapradesh': 'AP', - 'maharastra': 'MH', - 'mh': 'MH', - 'ap': 'AP', - 'dl': 'DL', - 'dd': 'DD', - 'br': 'BR', - 'ar': 'AR', - 'sk': 'SK', - 'kl': 'KL', - 'ga': 'GA', - 'rj': 'RJ', - 'rajastan': 'RJ', - 'rajasthan': 'RJ', - 'hp': 'HP', - 'ua': 'UA', - 'up': 'UP', - 'mp': 'MP', - 'mz': 'MZ', - 'bengal': 'WB', - 'westbengal': 'WB', - 'mizo': 'MZ', - 'orisa': 'OR', - 'odisa': 'OR', - 'or': 'OR', - 'ar': 'AR', - - } - diff --git a/django/contrib/localflavor/in_/__init__.py b/django/contrib/localflavor/in_/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/django/contrib/localflavor/in_/forms.py b/django/contrib/localflavor/in_/forms.py new file mode 100644 index 0000000000..5febc40e67 --- /dev/null +++ b/django/contrib/localflavor/in_/forms.py @@ -0,0 +1,49 @@ +""" +India-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 + + +class INZipCodeField(RegexField): + def __init__(self, *args, **kwargs): + super(INZipCodeField, self).__init__(r'^\d{6}$', + max_length=None, min_length=None, + error_message=gettext(u'Enter a zip code in the format XXXXXXX.'), + *args, **kwargs) + +class INStateField(Field): + """ + A form field that validates its input is a Indian state name or + abbreviation. It normalizes the input to the standard two-letter vehicle + registration abbreviation for the given state or union territory + """ + def clean(self, value): + from in_states import STATES_NORMALIZED + super(INStateField, self).clean(value) + if value in EMPTY_VALUES: + return u'' + try: + value = value.strip().lower() + except AttributeError: + pass + else: + try: + return smart_unicode(STATES_NORMALIZED[value.strip().lower()]) + except KeyError: + pass + raise ValidationError(u'Enter a Indian state or territory.') + +class INStateSelect(Select): + """ + A Select widget that uses a list of Indian states/territories as its + choices. + """ + def __init__(self, attrs=None): + from in_states import STATE_CHOICES + super(INStateSelect, self).__init__(attrs, choices=STATE_CHOICES) + diff --git a/django/contrib/localflavor/in_/in_states.py b/django/contrib/localflavor/in_/in_states.py new file mode 100644 index 0000000000..498efe7069 --- /dev/null +++ b/django/contrib/localflavor/in_/in_states.py @@ -0,0 +1,84 @@ +""" +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 = ( + 'KA', 'Karnataka', + 'AP', 'Andhra Pradesh', + 'KL', 'Kerala', + 'TN', 'Tamil Nadu', + 'MH', 'Maharashtra', + 'UP', 'Uttar Pradesh', + 'GA', 'Goa', + 'GJ', 'Gujarat', + 'RJ', 'Rajasthan', + 'HP', 'Himachal Pradesh', + 'JK', 'Jammu and Kashmir', + 'AR', 'Arunachal Pradesh', + 'AS', 'Assam', + 'BR', 'Bihar', + 'CG', 'Chattisgarh', + 'HR', 'Haryana', + 'JH', 'Jharkhand', + 'MP', 'Madhya Pradesh', + 'MN', 'Manipur', + 'ML', 'Meghalaya', + 'MZ', 'Mizoram', + 'NL', 'Nagaland', + 'OR', 'Orissa', + 'PB', 'Punjab', + 'SK', 'Sikkim', + 'TR', 'Tripura', + 'UA', 'Uttarakhand', + 'WB', 'West Bengal', + + # Union Territories + 'AN', 'Andaman and Nicobar', + 'CH', 'Chandigarh', + 'DN', 'Dadra and Nagar Haveli', + 'DD', 'Daman and Diu', + 'DL', 'Delhi', + 'LD', 'Lakshadweep', + 'PY', 'Pondicherry', +) + +STATES_NORMALIZED = { + 'ka': 'KA', + 'karnatka': 'KA', + 'tn': 'TN', + 'tamilnad': 'TN', + 'tamilnadu': 'TN', + 'andra pradesh': 'AP', + 'andrapradesh': 'AP', + 'andhrapradesh': 'AP', + 'maharastra': 'MH', + 'mh': 'MH', + 'ap': 'AP', + 'dl': 'DL', + 'dd': 'DD', + 'br': 'BR', + 'ar': 'AR', + 'sk': 'SK', + 'kl': 'KL', + 'ga': 'GA', + 'rj': 'RJ', + 'rajastan': 'RJ', + 'rajasthan': 'RJ', + 'hp': 'HP', + 'ua': 'UA', + 'up': 'UP', + 'mp': 'MP', + 'mz': 'MZ', + 'bengal': 'WB', + 'westbengal': 'WB', + 'mizo': 'MZ', + 'orisa': 'OR', + 'odisa': 'OR', + 'or': 'OR', + 'ar': 'AR', +} + -- cgit v1.3