~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to django/contrib/localflavor/fi/forms.py

  • Committer: Package Import Robot
  • Author(s): Luke Faraone, Jakub Wilk, Luke Faraone
  • Date: 2013-05-09 15:10:47 UTC
  • mfrom: (6.2.12 experimental)
  • Revision ID: package-import@ubuntu.com-20130509151047-g79qsrewg1yl43h5
Tags: 1.5.1-2
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Luke Faraone ]
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
FI-specific Form helpers
3
3
"""
4
4
 
5
 
from __future__ import absolute_import
 
5
from __future__ import absolute_import, unicode_literals
6
6
 
7
7
import re
8
8
 
36
36
    def clean(self, value):
37
37
        super(FISocialSecurityNumber, self).clean(value)
38
38
        if value in EMPTY_VALUES:
39
 
            return u''
 
39
            return ''
40
40
 
41
41
        checkmarks = "0123456789ABCDEFHJKLMNPRSTUVWXY"
42
42
        result = re.match(r"""^
51
51
        gd = result.groupdict()
52
52
        checksum = int(gd['date'] + gd['serial'])
53
53
        if checkmarks[checksum % len(checkmarks)] == gd['checksum'].upper():
54
 
            return u'%s' % value.upper()
 
54
            return '%s' % value.upper()
55
55
        raise ValidationError(self.error_messages['invalid'])