Django

Code

Ticket #7686: atlocalflavor.diff

File atlocalflavor.diff, 1.8 kB (added by bernd, 2 years ago)

patch for AT localflavors

  • django/contrib/localflavor/at/forms.py

    old new  
     1""" 
     2AT-specific Form helpers 
     3""" 
     4 
     5from django.utils.translation import ugettext_lazy as _ 
     6from django.newforms.fields import Field, RegexField, Select 
     7import re 
     8 
     9class ATZipCodeField(RegexField): 
     10    """ 
     11    A form field that validates its input is a Austrian postcode. 
     12     
     13    Accepts 4 digits 
     14    """ 
     15    default_error_messages = { 
     16        'invalid': _('Enter a zip code in the format XXXX.'), 
     17    } 
     18    def __init__(self, *args, **kwargs): 
     19        super(ATZipCodeField, self).__init__(r'^\d{4}$', 
     20            max_length=None, min_length=None, *args, **kwargs) 
     21 
     22class ATStateSelect(Select): 
     23    """ 
     24    A Select widget that uses a list of AT states as its choices. 
     25    """ 
     26    def __init__(self, attrs=None): 
     27        from at_states import STATE_CHOICES 
     28        super(ATStateSelect, self).__init__(attrs, choices=STATE_CHOICES) 
  • django/contrib/localflavor/at/at_states.py

    old new  
     1# -*- coding: utf-8 -* 
     2from django.utils.translation import ugettext_lazy as _ 
     3 
     4STATE_CHOICES = ( 
     5    ('BL', _('Burgenland')), 
     6    ('KA', _('Carinthia')), 
     7    ('NO', _('Lower Austria')), 
     8    ('OO', _('Upper Austria')), 
     9    ('SA', _('Salzburg')), 
     10    ('ST', _('Styria')), 
     11    ('TI', _('Tyrol')), 
     12    ('VO', _('Vorarlberg')), 
     13    ('WI', _('Vienna')), 
     14)