Skip to content

Commit

Permalink
Fixed #14860 -- PLPESELField, PLNIPField, and PLREGONField didn't han…
Browse files Browse the repository at this point in the history
…dle all EMPTY_VALUES correctly. Also converted teh Polish localflavor doctests into unittests. We have always been at war with doctests. Thanks to Idan Gazit.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14949 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
alex committed Dec 18, 2010
1 parent 187a11e commit f9e6ca1
Show file tree
Hide file tree
Showing 4 changed files with 467 additions and 89 deletions.
7 changes: 7 additions & 0 deletions django/contrib/localflavor/pl/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.forms import ValidationError
from django.forms.fields import Select, RegexField
from django.utils.translation import ugettext_lazy as _
from django.core.validators import EMPTY_VALUES

class PLProvinceSelect(Select):
"""
Expand Down Expand Up @@ -45,6 +46,8 @@ def __init__(self, *args, **kwargs):

def clean(self,value):
super(PLPESELField, self).clean(value)
if value in EMPTY_VALUES:
return u''
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
return u'%s' % value
Expand Down Expand Up @@ -78,6 +81,8 @@ def __init__(self, *args, **kwargs):

def clean(self,value):
super(PLNIPField, self).clean(value)
if value in EMPTY_VALUES:
return u''
value = re.sub("[-]", "", value)
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
Expand Down Expand Up @@ -116,6 +121,8 @@ def __init__(self, *args, **kwargs):

def clean(self,value):
super(PLREGONField, self).clean(value)
if value in EMPTY_VALUES:
return u''
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
return u'%s' % value
Expand Down
Loading

0 comments on commit f9e6ca1

Please sign in to comment.