Changeset 6926 for django/trunk/django/contrib/localflavor/no
- Timestamp:
- 12/17/07 02:05:27 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/localflavor/no/forms.py
r5876 r6926 9 9 10 10 class NOZipCodeField(RegexField): 11 default_error_messages = { 12 'invalid': ugettext('Enter a zip code in the format XXXX.'), 13 } 14 11 15 def __init__(self, *args, **kwargs): 12 16 super(NOZipCodeField, self).__init__(r'^\d{4}$', 13 max_length=None, min_length=None, 14 error_message=ugettext('Enter a zip code in the format XXXX.'), 15 *args, **kwargs) 17 max_length=None, min_length=None, *args, **kwargs) 16 18 17 19 class NOMunicipalitySelect(Select): … … 28 30 Algorithm is documented at http://no.wikipedia.org/wiki/Personnummer 29 31 """ 32 default_error_messages = { 33 'invalid': ugettext(u'Enter a valid Norwegian social security number.'), 34 } 35 30 36 def clean(self, value): 31 37 super(NOSocialSecurityNumber, self).clean(value) … … 33 39 return u'' 34 40 35 msg = ugettext(u'Enter a valid Norwegian social security number.')36 41 if not re.match(r'^\d{11}$', value): 37 raise ValidationError( msg)42 raise ValidationError(self.error_messages['invalid']) 38 43 39 44 day = int(value[:2]) … … 53 58 self.birthday = datetime.date(1900+year2, month, day) 54 59 except ValueError: 55 raise ValidationError( msg)60 raise ValidationError(self.error_messages['invalid']) 56 61 57 62 sexnum = int(value[8]) … … 69 74 70 75 if multiply_reduce(digits, weight_1) % 11 != 0: 71 raise ValidationError( msg)76 raise ValidationError(self.error_messages['invalid']) 72 77 if multiply_reduce(digits, weight_2) % 11 != 0: 73 raise ValidationError( msg)78 raise ValidationError(self.error_messages['invalid']) 74 79 75 80 return value
