Author: mtredinnick
Date: 2007-08-11 20:19:54 -0500 (Sat, 11 Aug 2007)
New Revision: 5856
Added:
django/trunk/django/contrib/localflavor/in_/
django/trunk/django/contrib/localflavor/in_/__init__.py
django/trunk/django/contrib/localflavor/in_/forms.py
django/trunk/django/contrib/localflavor/in_/in_states.py
Removed:
django/trunk/django/contrib/in_/__init__.py
django/trunk/django/contrib/in_/forms.py
django/trunk/django/contrib/in_/in_states.py
Log:
Moved in_ directory to its correct location under localflavor. I committed it
in the wrong place in [5847]. Fixed #3986.
Deleted: django/trunk/django/contrib/in_/__init__.py
===================================================================
--- django/trunk/django/contrib/in_/__init__.py 2007-08-11 12:10:23 UTC (rev
5855)
+++ django/trunk/django/contrib/in_/__init__.py 2007-08-12 01:19:54 UTC (rev
5856)
@@ -1 +0,0 @@
-# __init__.py
Deleted: django/trunk/django/contrib/in_/forms.py
===================================================================
--- django/trunk/django/contrib/in_/forms.py 2007-08-11 12:10:23 UTC (rev
5855)
+++ django/trunk/django/contrib/in_/forms.py 2007-08-12 01:19:54 UTC (rev
5856)
@@ -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)
-
Deleted: django/trunk/django/contrib/in_/in_states.py
===================================================================
--- django/trunk/django/contrib/in_/in_states.py 2007-08-11 12:10:23 UTC
(rev 5855)
+++ django/trunk/django/contrib/in_/in_states.py 2007-08-12 01:19:54 UTC
(rev 5856)
@@ -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',
-
- }
-
Added: django/trunk/django/contrib/localflavor/in_/__init__.py
===================================================================
Copied: django/trunk/django/contrib/localflavor/in_/forms.py (from rev 5855,
django/trunk/django/contrib/in_/forms.py)
===================================================================
--- django/trunk/django/contrib/localflavor/in_/forms.py
(rev 0)
+++ django/trunk/django/contrib/localflavor/in_/forms.py 2007-08-12
01:19:54 UTC (rev 5856)
@@ -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)
+
Copied: django/trunk/django/contrib/localflavor/in_/in_states.py (from rev
5855, django/trunk/django/contrib/in_/in_states.py)
===================================================================
--- django/trunk/django/contrib/localflavor/in_/in_states.py
(rev 0)
+++ django/trunk/django/contrib/localflavor/in_/in_states.py 2007-08-12
01:19:54 UTC (rev 5856)
@@ -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',
+}
+
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---