Permalink
Browse files

Fixed inconsistent indentation in localflavor/de/forms.py from [4922]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4939 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 07f599c commit e3308e19767ac1345c6c39459641c9a90677604b @adrianholovaty adrianholovaty committed Apr 6, 2007
Showing with 27 additions and 35 deletions.
  1. +21 −29 django/contrib/localflavor/de/forms.py
  2. +6 −6 tests/regressiontests/forms/localflavor.py
@@ -12,9 +12,9 @@
class DEZipCodeField(RegexField):
def __init__(self, *args, **kwargs):
super(DEZipCodeField, self).__init__(r'^\d{5}$',
- max_length=None, min_length=None,
- error_message=gettext(u'Enter a zip code in the format XXXXX.'),
- *args, **kwargs)
+ max_length=None, min_length=None,
+ error_message=gettext(u'Enter a zip code in the format XXXXX.'),
+ *args, **kwargs)
class DEStateSelect(Select):
"""
@@ -43,45 +43,37 @@ def has_valid_checksum(self, number):
parameter = 7
for i in range(len(given_number)):
- fragment = str(int(given_number[i])*parameter)
- if fragment.isalnum():
- calculated_checksum += int(fragment[-1])
-
- if parameter == 1:
- parameter = 7
- elif parameter == 3:
- parameter = 1
- elif parameter ==7:
- parameter = 3
-
- if str(calculated_checksum)[-1] == given_checksum:
- return True
- return False
+ fragment = str(int(given_number[i]) * parameter)
+ if fragment.isalnum():
+ calculated_checksum += int(fragment[-1])
+ if parameter == 1:
+ parameter = 7
+ elif parameter == 3:
+ parameter = 1
+ elif parameter ==7:
+ parameter = 3
+
+ return str(calculated_checksum)[-1] == given_checksum
def clean(self, value):
super(DEIdentityCardNumberField, self).clean(value)
- error_msg = gettext(u'Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format')
+ error_msg = gettext(u'Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.')
if value in EMPTY_VALUES:
return u''
match = re.match(id_re, value)
if not match:
raise ValidationError(error_msg)
- residence, origin, birthday, validity, checksum = \
- match.groupdict()['residence'], match.groupdict()['origin'], \
- match.groupdict()['birthday'], match.groupdict()['validity'], \
- match.groupdict()['checksum']
+ gd = match.groupdict()
+ residence, origin = gd['residence'], gd['origin']
+ birthday, validity, checksum = gd['birthday'], gd['validity'], gd['checksum']
- if residence == '0000000000' or \
- birthday == '0000000' or \
- validity == '0000000':
+ if residence == '0000000000' or birthday == '0000000' or validity == '0000000':
raise ValidationError(error_msg)
all_digits = "%s%s%s%s" % (residence, birthday, validity, checksum)
- if not self.has_valid_checksum(residence) or \
- not self.has_valid_checksum(birthday) or \
- not self.has_valid_checksum(validity) or \
- not self.has_valid_checksum(all_digits):
+ if not self.has_valid_checksum(residence) or not self.has_valid_checksum(birthday) or \
+ not self.has_valid_checksum(validity) or not self.has_valid_checksum(all_digits):
raise ValidationError(error_msg)
return u'%s%s-%s-%s-%s' % (residence, origin, birthday, validity, checksum)
Oops, something went wrong.

0 comments on commit e3308e1

Please sign in to comment.