| 1 |
""" |
|---|
| 2 |
AT-specific Form helpers |
|---|
| 3 |
""" |
|---|
| 4 |
|
|---|
| 5 |
from django.newforms.fields import RegexField, Select |
|---|
| 6 |
from django.utils.translation import ugettext |
|---|
| 7 |
|
|---|
| 8 |
class ATZipCodeField(RegexField): |
|---|
| 9 |
default_error_messages = { |
|---|
| 10 |
'invalid': ugettext('Enter a zip code in the format XXXX.'), |
|---|
| 11 |
} |
|---|
| 12 |
|
|---|
| 13 |
def __init__(self, *args, **kwargs): |
|---|
| 14 |
super(ATZipCodeField, self).__init__(r'^\d{4}$', |
|---|
| 15 |
max_length=None, min_length=None, *args, **kwargs) |
|---|
| 16 |
|
|---|
| 17 |
class ATProvinceSelect(Select): |
|---|
| 18 |
def __init__(self, attrs=None): |
|---|
| 19 |
from at_provinces import PROVINCE_CHOICES |
|---|
| 20 |
super(ATProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES) |
|---|