Small formatting changes to localflavor/is_/forms.py
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5095 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
bf89e4b151
commit
af6ed6c91d
|
@ -1,12 +1,12 @@
|
||||||
"""
|
"""
|
||||||
Iceland specific form helpers.
|
Iceland specific form helpers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.newforms import ValidationError
|
from django.newforms import ValidationError
|
||||||
from django.newforms.fields import RegexField, EMPTY_VALUES
|
from django.newforms.fields import RegexField, EMPTY_VALUES
|
||||||
from django.newforms.widgets import Select
|
from django.newforms.widgets import Select
|
||||||
from django.utils.translation import gettext
|
from django.utils.translation import gettext
|
||||||
|
|
||||||
|
|
||||||
class ISIdNumberField(RegexField):
|
class ISIdNumberField(RegexField):
|
||||||
"""
|
"""
|
||||||
Icelandic identification number (kennitala). This is a number every citizen
|
Icelandic identification number (kennitala). This is a number every citizen
|
||||||
|
@ -15,7 +15,6 @@ class ISIdNumberField(RegexField):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
error_msg = gettext(u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.')
|
error_msg = gettext(u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.')
|
||||||
kwargs['min_length'],kwargs['max_length'] = 10,11
|
kwargs['min_length'],kwargs['max_length'] = 10,11
|
||||||
|
|
||||||
super(ISIdNumberField, self).__init__(r'^\d{6}(-| )?\d{4}$', error_message=error_msg, *args, **kwargs)
|
super(ISIdNumberField, self).__init__(r'^\d{6}(-| )?\d{4}$', error_message=error_msg, *args, **kwargs)
|
||||||
|
|
||||||
def clean(self, value):
|
def clean(self, value):
|
||||||
|
@ -30,7 +29,6 @@ class ISIdNumberField(RegexField):
|
||||||
else:
|
else:
|
||||||
raise ValidationError(gettext(u'The Icelandic identification number is not valid.'))
|
raise ValidationError(gettext(u'The Icelandic identification number is not valid.'))
|
||||||
|
|
||||||
|
|
||||||
def _canonify(self, value):
|
def _canonify(self, value):
|
||||||
"""
|
"""
|
||||||
Returns the value as only digits.
|
Returns the value as only digits.
|
||||||
|
@ -52,7 +50,6 @@ class ISIdNumberField(RegexField):
|
||||||
"""
|
"""
|
||||||
return value[:6]+'-'+value[6:]
|
return value[:6]+'-'+value[6:]
|
||||||
|
|
||||||
|
|
||||||
class ISPhoneNumberField(RegexField):
|
class ISPhoneNumberField(RegexField):
|
||||||
"""
|
"""
|
||||||
Icelandic phone number. Seven digits with an optional hyphen or space after
|
Icelandic phone number. Seven digits with an optional hyphen or space after
|
||||||
|
@ -70,7 +67,6 @@ class ISPhoneNumberField(RegexField):
|
||||||
|
|
||||||
return value.replace('-', '').replace(' ', '')
|
return value.replace('-', '').replace(' ', '')
|
||||||
|
|
||||||
|
|
||||||
class ISPostalCodeSelect(Select):
|
class ISPostalCodeSelect(Select):
|
||||||
"""
|
"""
|
||||||
A Select widget that uses a list of Icelandic postal codes as its choices.
|
A Select widget that uses a list of Icelandic postal codes as its choices.
|
||||||
|
|
Loading…
Reference in New Issue