Commit 4b3198d1 authored by Alex Gaynor's avatar Alex Gaynor
Browse files

[1.2.X] Fixed #14860 -- PLPESELField, PLNIPField, and PLREGONField didn't...

[1.2.X] Fixed #14860 -- PLPESELField, PLNIPField, and PLREGONField didn't handle all EMPTY_VALUES correctly.  Also converted teh Polish localflavor doctests into unittests.  We have always been at war with doctests.  Thanks to Idan Gazit.  Backport of [14949].

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14973 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent a15aa669
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import re
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):
    """
@@ -45,6 +46,8 @@ class PLPESELField(RegexField):

    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
@@ -78,6 +81,8 @@ class PLNIPField(RegexField):

    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'])
@@ -116,6 +121,8 @@ class PLREGONField(RegexField):

    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
+458 −87

File changed.

Preview size limit exceeded, changes collapsed.

+1 −2
Original line number Diff line number Diff line
# -*- coding: utf-8 -*-
from localflavor.cz import tests as localflavor_cz_tests
from localflavor.pl import tests as localflavor_pl_tests
from localflavor.pt import tests as localflavor_pt_tests
from localflavor.ro import tests as localflavor_ro_tests
from localflavor.se import tests as localflavor_se_tests
@@ -30,11 +29,11 @@ from localflavor.it import ITLocalFlavorTests
from localflavor.jp import JPLocalFlavorTests
from localflavor.kw import KWLocalFlavorTests
from localflavor.nl import NLLocalFlavorTests
from localflavor.pl import PLLocalFlavorTests


__test__ = {
    'localflavor_cz_tests': localflavor_cz_tests,
    'localflavor_pl_tests': localflavor_pl_tests,
    'localflavor_pt_tests': localflavor_pt_tests,
    'localflavor_ro_tests': localflavor_ro_tests,
    'localflavor_se_tests': localflavor_se_tests,
+1 −0
Original line number Diff line number Diff line
@@ -32,4 +32,5 @@ from regressiontests.forms.localflavortests import (
    JPLocalFlavorTests,
    KWLocalFlavorTests,
    NLLocalFlavorTests,
    PLLocalFlavorTests,
)