Remove all relative imports. We have always been at war with relative imports.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17009 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2011-10-18 00:47:49 +00:00
parent 66210cbc70
commit 396fcaaef9
40 changed files with 218 additions and 106 deletions

View File

@ -3,18 +3,21 @@
AR-specific Form helpers.
"""
from django.forms import ValidationError
from __future__ import absolute_import
from django.contrib.localflavor.ar.ar_provinces import PROVINCE_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import RegexField, CharField, Select
from django.utils.translation import ugettext_lazy as _
class ARProvinceSelect(Select):
"""
A Select widget that uses a list of Argentinean provinces/autonomous cities
as its choices.
"""
def __init__(self, attrs=None):
from ar_provinces import PROVINCE_CHOICES
super(ARProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
class ARPostalCodeField(RegexField):

View File

@ -1,14 +1,19 @@
"""
Australian-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.au.au_states import STATE_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
PHONE_DIGITS_RE = re.compile(r'^(\d{10})$')
class AUPostCodeField(RegexField):
@ -52,5 +57,4 @@ class AUStateSelect(Select):
choices.
"""
def __init__(self, attrs=None):
from au_states import STATE_CHOICES
super(AUStateSelect, self).__init__(attrs, choices=STATE_CHOICES)

View File

@ -1,13 +1,19 @@
"""
Belgium-specific Form helpers
"""
from __future__ import absolute_import
from django.contrib.localflavor.be.be_provinces import PROVINCE_CHOICES
from django.contrib.localflavor.be.be_regions import REGION_CHOICES
from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _
class BEPostalCodeField(RegexField):
"""
A form field that validates its input as a belgium postal code.
Belgium postal code is a 4 digits string. The first digit indicates
the province (except for the 3ddd numbers that are shared by the
eastern part of Flemish Brabant and Limburg and the and 1ddd that
@ -28,14 +34,14 @@ class BEPhoneNumberField(RegexField):
A form field that validates its input as a belgium phone number.
Landlines have a seven-digit subscriber number and a one-digit area code,
while smaller cities have a six-digit subscriber number and a two-digit
area code. Cell phones have a six-digit subscriber number and a two-digit
while smaller cities have a six-digit subscriber number and a two-digit
area code. Cell phones have a six-digit subscriber number and a two-digit
area code preceeded by the number 4.
0d ddd dd dd, 0d/ddd.dd.dd, 0d.ddd.dd.dd,
0d ddd dd dd, 0d/ddd.dd.dd, 0d.ddd.dd.dd,
0dddddddd - dialling a bigger city
0dd dd dd dd, 0dd/dd.dd.dd, 0dd.dd.dd.dd,
0dd dd dd dd, 0dd/dd.dd.dd, 0dd.dd.dd.dd,
0dddddddd - dialling a smaller city
04dd ddd dd dd, 04dd/ddd.dd.dd,
04dd ddd dd dd, 04dd/ddd.dd.dd,
04dd.ddd.dd.dd, 04ddddddddd - dialling a mobile number
"""
default_error_messages = {
@ -55,7 +61,6 @@ class BERegionSelect(Select):
A Select widget that uses a list of belgium regions as its choices.
"""
def __init__(self, attrs=None):
from be_regions import REGION_CHOICES
super(BERegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class BEProvinceSelect(Select):
@ -63,5 +68,4 @@ class BEProvinceSelect(Select):
A Select widget that uses a list of belgium provinces as its choices.
"""
def __init__(self, attrs=None):
from be_provinces import PROVINCE_CHOICES
super(BEProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)

View File

@ -3,12 +3,17 @@
BR-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.br.br_states import STATE_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, CharField, Select
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re
phone_digits_re = re.compile(r'^(\d{2})[-\.]?(\d{4})[-\.]?(\d{4})$')
@ -42,7 +47,6 @@ class BRStateSelect(Select):
as its choices.
"""
def __init__(self, attrs=None):
from br_states import STATE_CHOICES
super(BRStateSelect, self).__init__(attrs, choices=STATE_CHOICES)
class BRStateChoiceField(Field):
@ -58,7 +62,6 @@ class BRStateChoiceField(Field):
initial=None, help_text=None):
super(BRStateChoiceField, self).__init__(required, widget, label,
initial, help_text)
from br_states import STATE_CHOICES
self.widget.choices = STATE_CHOICES
def clean(self, value):

View File

@ -2,12 +2,17 @@
Canada-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.ca.ca_provinces import PROVINCE_CHOICES, PROVINCES_NORMALIZED
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, CharField, Select
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re
phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
sin_re = re.compile(r"^(\d{3})-(\d{3})-(\d{3})$")
@ -66,7 +71,6 @@ class CAProvinceField(Field):
}
def clean(self, value):
from ca_provinces import PROVINCES_NORMALIZED
super(CAProvinceField, self).clean(value)
if value in EMPTY_VALUES:
return u''
@ -87,7 +91,6 @@ class CAProvinceSelect(Select):
territories as its choices.
"""
def __init__(self, attrs=None):
from ca_provinces import PROVINCE_CHOICES # relative import
super(CAProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
class CASocialInsuranceNumberField(Field):

View File

@ -2,12 +2,17 @@
Swiss-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.ch.ch_states import STATE_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re
id_re = re.compile(r"^(?P<idnumber>\w{8})(?P<pos9>(\d{1}|<))(?P<checksum>\d{1})$")
phone_digits_re = re.compile(r'^0([1-9]{1})\d{8}$')
@ -47,7 +52,6 @@ class CHStateSelect(Select):
A Select widget that uses a list of CH states as its choices.
"""
def __init__(self, attrs=None):
from ch_states import STATE_CHOICES # relative import
super(CHStateSelect, self).__init__(attrs, choices=STATE_CHOICES)
class CHIdentityCardNumberField(Field):

View File

@ -2,6 +2,9 @@
Chile specific form helpers.
"""
from __future__ import absolute_import
from django.contrib.localflavor.cl.cl_regions import REGION_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import RegexField, Select
@ -15,7 +18,6 @@ class CLRegionSelect(Select):
as its choices.
"""
def __init__(self, attrs=None):
from cl_regions import REGION_CHOICES
super(CLRegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class CLRutField(RegexField):

View File

@ -3,8 +3,11 @@
"""
Chinese-specific form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.cn.cn_provinces import CN_PROVINCE_CHOICES
from django.forms import ValidationError
from django.forms.fields import CharField, RegexField, Select
from django.utils.translation import ugettext_lazy as _
@ -67,7 +70,6 @@ class CNProvinceSelect(Select):
A select widget with list of Chinese provinces as choices.
"""
def __init__(self, attrs=None):
from cn_provinces import CN_PROVINCE_CHOICES
super(CNProvinceSelect, self).__init__(
attrs, choices=CN_PROVINCE_CHOICES,
)

View File

@ -2,12 +2,15 @@
Colombian-specific form helpers.
"""
from __future__ import absolute_import
from django.contrib.localflavor.co.co_departments import DEPARTMENT_CHOICES
from django.forms.fields import Select
class CODepartmentSelect(Select):
"""
A Select widget that uses a list of Colombian states as its choices.
"""
def __init__(self, attrs=None):
from co_departments import DEPARTMENT_CHOICES
super(CODepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_CHOICES)

View File

@ -2,11 +2,16 @@
Czech-specific form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.cz.cz_regions import REGION_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Select, RegexField, Field
from django.utils.translation import ugettext_lazy as _
import re
birth_number = re.compile(r'^(?P<birth>\d{6})/?(?P<id>\d{3,4})$')
ic_number = re.compile(r'^(?P<number>\d{7})(?P<check>\d)$')
@ -16,7 +21,6 @@ class CZRegionSelect(Select):
A select widget widget with list of Czech regions as choices.
"""
def __init__(self, attrs=None):
from cz_regions import REGION_CHOICES
super(CZRegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class CZPostalCodeField(RegexField):

View File

@ -2,11 +2,16 @@
DE-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.de.de_states import STATE_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select
from django.utils.translation import ugettext_lazy as _
import re
id_re = re.compile(r"^(?P<residence>\d{10})(?P<origin>\w{1,3})[-\ ]?(?P<birthday>\d{7})[-\ ]?(?P<validity>\d{7})[-\ ]?(?P<checksum>\d{1})$")
@ -23,7 +28,6 @@ class DEStateSelect(Select):
A Select widget that uses a list of DE states as its choices.
"""
def __init__(self, attrs=None):
from de_states import STATE_CHOICES
super(DEStateSelect, self).__init__(attrs, choices=STATE_CHOICES)
class DEIdentityCardNumberField(Field):

View File

@ -2,6 +2,9 @@
Ecuador-specific form helpers.
"""
from __future__ import absolute_import
from django.contrib.localflavor.ec.ec_provinces import PROVINCE_CHOICES
from django.forms.fields import Select
class ECProvinceSelect(Select):
@ -9,5 +12,4 @@ class ECProvinceSelect(Select):
A Select widget that uses a list of Ecuador provinces as its choices.
"""
def __init__(self, attrs=None):
from ec_provinces import PROVINCE_CHOICES
super(ECProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)

View File

@ -3,11 +3,17 @@
Spanish-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.es.es_provinces import PROVINCE_CHOICES
from django.contrib.localflavor.es.es_regions import REGION_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _
import re
class ESPostalCodeField(RegexField):
"""
@ -166,7 +172,6 @@ class ESRegionSelect(Select):
A Select widget that uses a list of spanish regions as its choices.
"""
def __init__(self, attrs=None):
from es_regions import REGION_CHOICES
super(ESRegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class ESProvinceSelect(Select):
@ -174,7 +179,6 @@ class ESProvinceSelect(Select):
A Select widget that uses a list of spanish provinces as its choices.
"""
def __init__(self, attrs=None):
from es_provinces import PROVINCE_CHOICES
super(ESProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)

View File

@ -2,12 +2,17 @@
FI-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.fi.fi_municipalities import MUNICIPALITY_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select
from django.utils.translation import ugettext_lazy as _
class FIZipCodeField(RegexField):
default_error_messages = {
'invalid': _('Enter a zip code in the format XXXXX.'),
@ -21,7 +26,6 @@ class FIMunicipalitySelect(Select):
A Select widget that uses a list of Finnish municipalities as its choices.
"""
def __init__(self, attrs=None):
from fi_municipalities import MUNICIPALITY_CHOICES
super(FIMunicipalitySelect, self).__init__(attrs, choices=MUNICIPALITY_CHOICES)
class FISocialSecurityNumber(Field):

View File

@ -1,13 +1,17 @@
"""
FR-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.fr.fr_department import DEPARTMENT_ASCII_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re
phone_digits_re = re.compile(r'^0\d(\s|\.)?(\d{2}(\s|\.)?){3}\d{2}$')
@ -46,6 +50,5 @@ class FRDepartmentSelect(Select):
A Select widget that uses a list of FR departments as its choices.
"""
def __init__(self, attrs=None):
from fr_department import DEPARTMENT_ASCII_CHOICES
super(FRDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_ASCII_CHOICES)

View File

@ -2,12 +2,16 @@
GB-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.gb.gb_regions import GB_NATIONS_CHOICES, GB_REGION_CHOICES
from django.forms.fields import CharField, Select
from django.forms import ValidationError
from django.utils.translation import ugettext_lazy as _
class GBPostcodeField(CharField):
"""
A form field that validates its input is a UK postcode.
@ -41,7 +45,6 @@ class GBCountySelect(Select):
A Select widget that uses a list of UK Counties/Regions as its choices.
"""
def __init__(self, attrs=None):
from gb_regions import GB_REGION_CHOICES
super(GBCountySelect, self).__init__(attrs, choices=GB_REGION_CHOICES)
class GBNationSelect(Select):
@ -49,5 +52,4 @@ class GBNationSelect(Select):
A Select widget that uses a list of UK Nations as its choices.
"""
def __init__(self, attrs=None):
from gb_regions import GB_NATIONS_CHOICES
super(GBNationSelect, self).__init__(attrs, choices=GB_NATIONS_CHOICES)

View File

@ -2,13 +2,19 @@
"""
HR-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.forms.fields import Field, Select, RegexField
from django.contrib.localflavor.hr.hr_choices import (
HR_LICENSE_PLATE_PREFIX_CHOICES, HR_COUNTY_CHOICES,
HR_PHONE_NUMBER_PREFIX_CHOICES)
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.forms.fields import Field, Select, RegexField
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
jmbg_re = re.compile(r'^(?P<dd>\d{2})(?P<mm>\d{2})(?P<yyy>\d{3})' + \
r'(?P<rr>\d{2})(?P<bbb>\d{3})(?P<k>\d{1})$')
@ -26,7 +32,6 @@ class HRCountySelect(Select):
"""
def __init__(self, attrs=None):
from hr_choices import HR_COUNTY_CHOICES
super(HRCountySelect, self).__init__(attrs, choices=HR_COUNTY_CHOICES)
@ -37,7 +42,6 @@ class HRLicensePlatePrefixSelect(Select):
"""
def __init__(self, attrs=None):
from hr_choices import HR_LICENSE_PLATE_PREFIX_CHOICES
super(HRLicensePlatePrefixSelect, self).__init__(attrs,
choices=HR_LICENSE_PLATE_PREFIX_CHOICES)
@ -49,7 +53,6 @@ class HRPhoneNumberPrefixSelect(Select):
"""
def __init__(self, attrs=None):
from hr_choices import HR_PHONE_NUMBER_PREFIX_CHOICES
super(HRPhoneNumberPrefixSelect, self).__init__(attrs,
choices=HR_PHONE_NUMBER_PREFIX_CHOICES)
@ -163,7 +166,6 @@ class HRLicensePlateField(Field):
raise ValidationError(self.error_messages['invalid'])
# Make sure the prefix is in the list of known codes.
from hr_choices import HR_LICENSE_PLATE_PREFIX_CHOICES
prefix = matches.group('prefix')
if prefix not in [choice[0] for choice in HR_LICENSE_PLATE_PREFIX_CHOICES]:
raise ValidationError(self.error_messages['area'])
@ -230,7 +232,6 @@ class HRPhoneNumberField(Field):
raise ValidationError(self.error_messages['invalid'])
# Make sure the prefix is in the list of known codes.
from hr_choices import HR_PHONE_NUMBER_PREFIX_CHOICES
prefix = matches.group('prefix')
number = matches.group('number')
if prefix[0] == '1':

View File

@ -2,15 +2,19 @@
ID-specific Form helpers
"""
from __future__ import absolute_import
import re
import time
from django.core.validators import EMPTY_VALUES
from django.contrib.localflavor.id.id_choices import PROVINCE_CHOICES, LICENSE_PLATE_PREFIX_CHOICES
from django.forms import ValidationError
from django.forms.fields import Field, Select
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
postcode_re = re.compile(r'^[1-9]\d{4}$')
phone_re = re.compile(r'^(\+62|0)[2-9]\d{7,10}$')
plate_re = re.compile(r'^(?P<prefix>[A-Z]{1,2}) ' + \
@ -54,7 +58,6 @@ class IDProvinceSelect(Select):
"""
def __init__(self, attrs=None):
from id_choices import PROVINCE_CHOICES
super(IDProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
@ -90,7 +93,6 @@ class IDLicensePlatePrefixSelect(Select):
"""
def __init__(self, attrs=None):
from id_choices import LICENSE_PLATE_PREFIX_CHOICES
super(IDLicensePlatePrefixSelect, self).__init__(attrs,
choices=LICENSE_PLATE_PREFIX_CHOICES)
@ -120,7 +122,6 @@ class IDLicensePlateField(Field):
raise ValidationError(self.error_messages['invalid'])
# Make sure prefix is in the list of known codes.
from id_choices import LICENSE_PLATE_PREFIX_CHOICES
prefix = matches.group('prefix')
if prefix not in [choice[0] for choice in LICENSE_PLATE_PREFIX_CHOICES]:
raise ValidationError(self.error_messages['invalid'])

View File

@ -2,12 +2,15 @@
UK-specific Form helpers
"""
from __future__ import absolute_import
from django.contrib.localflavor.ie.ie_counties import IE_COUNTY_CHOICES
from django.forms.fields import Select
class IECountySelect(Select):
"""
A Select widget that uses a list of Irish Counties as its choices.
"""
def __init__(self, attrs=None):
from ie_counties import IE_COUNTY_CHOICES
super(IECountySelect, self).__init__(attrs, choices=IE_COUNTY_CHOICES)

View File

@ -1,14 +1,19 @@
"""
India-specific Form helpers.
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.in_.in_states import STATES_NORMALIZED, STATE_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, CharField, Select
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
phone_digits_re = re.compile(r"""
(
(?P<std_code> # the std-code group
@ -60,7 +65,6 @@ class INStateField(Field):
}
def clean(self, value):
from in_states import STATES_NORMALIZED
super(INStateField, self).clean(value)
if value in EMPTY_VALUES:
return u''
@ -82,7 +86,6 @@ class INStateSelect(Select):
choices.
"""
def __init__(self, attrs=None):
from in_states import STATE_CHOICES
super(INStateSelect, self).__init__(attrs, choices=STATE_CHOICES)

View File

@ -2,12 +2,16 @@
Iceland specific form helpers.
"""
from __future__ import absolute_import
from django.contrib.localflavor.is_.is_postalcodes import IS_POSTALCODES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import RegexField
from django.forms.widgets import Select
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
class ISIdNumberField(RegexField):
"""
@ -78,6 +82,5 @@ class ISPostalCodeSelect(Select):
A Select widget that uses a list of Icelandic postal codes as its choices.
"""
def __init__(self, attrs=None):
from is_postalcodes import IS_POSTALCODES
super(ISPostalCodeSelect, self).__init__(attrs, choices=IS_POSTALCODES)

View File

@ -2,13 +2,19 @@
IT-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.it.it_province import PROVINCE_CHOICES
from django.contrib.localflavor.it.it_region import REGION_CHOICES
from django.contrib.localflavor.it.util import ssn_check_digit, vat_number_check_digit
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.contrib.localflavor.it.util import ssn_check_digit, vat_number_check_digit
import re
class ITZipCodeField(RegexField):
default_error_messages = {
@ -23,7 +29,6 @@ class ITRegionSelect(Select):
A Select widget that uses a list of IT regions as its choices.
"""
def __init__(self, attrs=None):
from it_region import REGION_CHOICES
super(ITRegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class ITProvinceSelect(Select):
@ -31,7 +36,6 @@ class ITProvinceSelect(Select):
A Select widget that uses a list of IT provinces as its choices.
"""
def __init__(self, attrs=None):
from it_province import PROVINCE_CHOICES
super(ITProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
class ITSocialSecurityNumberField(RegexField):

View File

@ -2,8 +2,12 @@
JP-specific Form helpers
"""
from django.utils.translation import ugettext_lazy as _
from __future__ import absolute_import
from django.contrib.localflavor.jp.jp_prefectures import JP_PREFECTURES
from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _
class JPPostalCodeField(RegexField):
"""
@ -32,5 +36,4 @@ class JPPrefectureSelect(Select):
A Select widget that uses a list of Japanese prefectures as its choices.
"""
def __init__(self, attrs=None):
from jp_prefectures import JP_PREFECTURES
super(JPPrefectureSelect, self).__init__(attrs, choices=JP_PREFECTURES)

View File

@ -1,3 +1,5 @@
from __future__ import absolute_import
import datetime
from django.core.validators import EMPTY_VALUES
@ -5,7 +7,7 @@ from django.forms import ValidationError
from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _
from mk_choices import MK_MUNICIPALITIES
from django.contrib.localflavor.mk.mk_choices import MK_MUNICIPALITIES
class MKIdentityCardNumberField(RegexField):

View File

@ -2,13 +2,17 @@
NL-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.nl.nl_provinces import PROVINCE_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, Select
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
pc_re = re.compile('^\d{4}[A-Z]{2}$')
sofi_re = re.compile('^\d{9}$')
@ -42,7 +46,6 @@ class NLProvinceSelect(Select):
choices.
"""
def __init__(self, attrs=None):
from nl_provinces import PROVINCE_CHOICES
super(NLProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)
class NLPhoneNumberField(Field):

View File

@ -2,13 +2,18 @@
Norwegian-specific Form helpers
"""
from __future__ import absolute_import
import re
import datetime
from django.contrib.localflavor.no.no_municipalities import MUNICIPALITY_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select
from django.utils.translation import ugettext_lazy as _
class NOZipCodeField(RegexField):
default_error_messages = {
'invalid': _('Enter a zip code in the format XXXX.'),
@ -24,7 +29,6 @@ class NOMunicipalitySelect(Select):
as its choices.
"""
def __init__(self, attrs=None):
from no_municipalities import MUNICIPALITY_CHOICES
super(NOMunicipalitySelect, self).__init__(attrs, choices=MUNICIPALITY_CHOICES)
class NOSocialSecurityNumber(Field):

View File

@ -3,17 +3,20 @@
PE-specific Form helpers.
"""
from __future__ import absolute_import
from django.contrib.localflavor.pe.pe_region import REGION_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import RegexField, CharField, Select
from django.utils.translation import ugettext_lazy as _
class PERegionSelect(Select):
"""
A Select widget that uses a list of Peruvian Regions as its choices.
"""
def __init__(self, attrs=None):
from pe_region import REGION_CHOICES
super(PERegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class PEDNIField(CharField):

View File

@ -2,19 +2,23 @@
Polish-specific form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.pl.pl_administrativeunits import ADMINISTRATIVE_UNIT_CHOICES
from django.contrib.localflavor.pl.pl_voivodeships import VOIVODESHIP_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Select, RegexField
from django.utils.translation import ugettext_lazy as _
from django.core.validators import EMPTY_VALUES
class PLProvinceSelect(Select):
"""
A select widget with list of Polish administrative provinces as choices.
"""
def __init__(self, attrs=None):
from pl_voivodeships import VOIVODESHIP_CHOICES
super(PLProvinceSelect, self).__init__(attrs, choices=VOIVODESHIP_CHOICES)
class PLCountySelect(Select):
@ -22,7 +26,6 @@ class PLCountySelect(Select):
A select widget with list of Polish administrative units as choices.
"""
def __init__(self, attrs=None):
from pl_administrativeunits import ADMINISTRATIVE_UNIT_CHOICES
super(PLCountySelect, self).__init__(attrs, choices=ADMINISTRATIVE_UNIT_CHOICES)
class PLPESELField(RegexField):

View File

@ -1,14 +1,18 @@
"""
PY-specific Form helpers.
"""
from __future__ import absolute_import
from django.contrib.localflavor.py.py_department import DEPARTMENT_CHOICES, DEPARTMENT_ROMAN_CHOICES
from django.forms.fields import Select
class PyDepartmentSelect(Select):
"""
A Select widget with a list of Paraguayan departments as choices.
"""
def __init__(self, attrs=None):
from py_department import DEPARTMENT_CHOICES
super(PyDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_CHOICES)
@ -17,5 +21,4 @@ class PyNumberedDepartmentSelect(Select):
A Select widget with a roman numbered list of Paraguayan departments as choices.
"""
def __init__(self, attrs=None):
from py_department import DEPARTMENT_ROMAN_CHOICES
super(PyNumberedDepartmentSelect, self).__init__(attrs, choices=DEPARTMENT_ROMAN_CHOICES)

View File

@ -2,10 +2,14 @@
"""
Romanian specific form helpers.
"""
from __future__ import absolute_import
from django.contrib.localflavor.ro.ro_counties import COUNTIES_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError, Field, RegexField, Select
from django.utils.translation import ugettext_lazy as _
class ROCIFField(RegexField):
"""
A Romanian fiscal identity code (CIF) field
@ -100,7 +104,6 @@ class ROCountyField(Field):
}
def clean(self, value):
from ro_counties import COUNTIES_CHOICES
super(ROCountyField, self).clean(value)
if value in EMPTY_VALUES:
return u''
@ -127,7 +130,6 @@ class ROCountySelect(Select):
choices.
"""
def __init__(self, attrs=None):
from ro_counties import COUNTIES_CHOICES
super(ROCountySelect, self).__init__(attrs, choices=COUNTIES_CHOICES)
class ROIBANField(RegexField):

View File

@ -1,20 +1,22 @@
"""
Russian-specific forms helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.ru.ru_regions import RU_COUNTY_CHOICES, RU_REGIONS_CHOICES
from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _
phone_digits_re = re.compile(r'^(?:[78]-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
phone_digits_re = re.compile(r'^(?:[78]-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
class RUCountySelect(Select):
"""
A Select widget that uses a list of Russian Counties as its choices.
"""
def __init__(self, attrs=None):
from ru_regions import RU_COUNTY_CHOICES
super(RUCountySelect, self).__init__(attrs, choices=RU_COUNTY_CHOICES)
@ -23,7 +25,6 @@ class RURegionSelect(Select):
A Select widget that uses a list of Russian Regions as its choices.
"""
def __init__(self, attrs=None):
from ru_regions import RU_REGIONS_CHOICES
super(RURegionSelect, self).__init__(attrs, choices=RU_REGIONS_CHOICES)

View File

@ -2,14 +2,19 @@
"""
Swedish specific Form helpers
"""
from __future__ import absolute_import
import re
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.core.validators import EMPTY_VALUES
from django.contrib.localflavor.se.se_counties import COUNTY_CHOICES
from django.contrib.localflavor.se.utils import (id_number_checksum,
validate_id_birthday, format_personal_id_number, valid_organisation,
format_organisation_number)
__all__ = ('SECountySelect', 'SEOrganisationNumberField',
'SEPersonalIdentityNumberField', 'SEPostalCodeField')
@ -26,7 +31,6 @@ class SECountySelect(forms.Select):
"""
def __init__(self, attrs=None):
from se_counties import COUNTY_CHOICES
super(SECountySelect, self).__init__(attrs=attrs,
choices=COUNTY_CHOICES)
@ -52,20 +56,20 @@ class SEOrganisationNumberField(forms.CharField):
def clean(self, value):
value = super(SEOrganisationNumberField, self).clean(value)
if value in EMPTY_VALUES:
return u''
match = SWEDISH_ID_NUMBER.match(value)
if not match:
raise forms.ValidationError(self.error_messages['invalid'])
gd = match.groupdict()
# Compare the calculated value with the checksum
# Compare the calculated value with the checksum
if id_number_checksum(gd) != int(gd['checksum']):
raise forms.ValidationError(self.error_messages['invalid'])
# First: check if this is a real organisation_number
if valid_organisation(gd):
return format_organisation_number(gd)
@ -88,7 +92,7 @@ class SEPersonalIdentityNumberField(forms.CharField):
A + indicates that the person is older than 100 years, which will be taken
into consideration when the date is validated.
The checksum will be calculated and checked. The birth date is checked to
be a valid date.
@ -113,14 +117,14 @@ class SEPersonalIdentityNumberField(forms.CharField):
if value in EMPTY_VALUES:
return u''
match = SWEDISH_ID_NUMBER.match(value)
if match is None:
raise forms.ValidationError(self.error_messages['invalid'])
gd = match.groupdict()
# compare the calculated value with the checksum
# compare the calculated value with the checksum
if id_number_checksum(gd) != int(gd['checksum']):
raise forms.ValidationError(self.error_messages['invalid'])
@ -130,10 +134,10 @@ class SEPersonalIdentityNumberField(forms.CharField):
except ValueError:
raise forms.ValidationError(self.error_messages['invalid'])
# make sure that co-ordination numbers do not pass if not allowed
# make sure that co-ordination numbers do not pass if not allowed
if not self.coordination_number and int(gd['day']) > 60:
raise forms.ValidationError(self.error_messages['coordination_number'])
return format_personal_id_number(birth_day, gd)
@ -143,7 +147,7 @@ class SEPostalCodeField(forms.RegexField):
Valid codes consist of five digits (XXXXX). The number can optionally be
formatted with a space after the third digit (XXX XX).
The cleaned value will never contain the space.
The cleaned value will never contain the space.
"""
default_error_messages = {

View File

@ -2,12 +2,15 @@
Slovenian specific form helpers.
"""
from __future__ import absolute_import
import datetime
import re
from django.forms.fields import CharField, Select, ChoiceField
from django.contrib.localflavor.si.si_postalcodes import SI_POSTALCODES_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import CharField, Select, ChoiceField
from django.utils.translation import ugettext_lazy as _
@ -116,7 +119,6 @@ class SIPostalCodeField(ChoiceField):
"""
def __init__(self, *args, **kwargs):
from si_postalcodes import SI_POSTALCODES_CHOICES
kwargs.setdefault('choices', SI_POSTALCODES_CHOICES)
super(SIPostalCodeField, self).__init__(*args, **kwargs)
@ -125,7 +127,6 @@ class SIPostalCodeSelect(Select):
"""A Select widget that uses Slovenian postal codes as its choices.
"""
def __init__(self, attrs=None):
from si_postalcodes import SI_POSTALCODES_CHOICES
super(SIPostalCodeSelect, self).__init__(attrs,
choices=SI_POSTALCODES_CHOICES)

View File

@ -2,15 +2,19 @@
Slovak-specific form helpers
"""
from __future__ import absolute_import
from django.contrib.localflavor.sk.sk_districts import DISTRICT_CHOICES
from django.contrib.localflavor.sk.sk_regions import REGION_CHOICES
from django.forms.fields import Select, RegexField
from django.utils.translation import ugettext_lazy as _
class SKRegionSelect(Select):
"""
A select widget widget with list of Slovak regions as choices.
"""
def __init__(self, attrs=None):
from sk_regions import REGION_CHOICES
super(SKRegionSelect, self).__init__(attrs, choices=REGION_CHOICES)
class SKDistrictSelect(Select):
@ -18,7 +22,6 @@ class SKDistrictSelect(Select):
A select widget with list of Slovak districts as choices.
"""
def __init__(self, attrs=None):
from sk_districts import DISTRICT_CHOICES
super(SKDistrictSelect, self).__init__(attrs, choices=DISTRICT_CHOICES)
class SKPostalCodeField(RegexField):

View File

@ -2,12 +2,17 @@
TR-specific Form helpers
"""
from __future__ import absolute_import
import re
from django.contrib.localflavor.tr.tr_provinces import PROVINCE_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select, CharField
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
import re
phone_digits_re = re.compile(r'^(\+90|0)? ?(([1-9]\d{2})|\([1-9]\d{2}\)) ?([2-9]\d{2} ?\d{2} ?\d{2})$')
@ -87,5 +92,4 @@ class TRProvinceSelect(Select):
A Select widget that uses a list of provinces in Turkey as its choices.
"""
def __init__(self, attrs=None):
from tr_provinces import PROVINCE_CHOICES
super(TRProvinceSelect, self).__init__(attrs, choices=PROVINCE_CHOICES)

View File

@ -1,2 +1,4 @@
from api import *
from constants import *
from __future__ import absolute_import
from django.contrib.messages.api import *
from django.contrib.messages.constants import *

View File

@ -1,7 +1,9 @@
from query import *
from subqueries import *
from __future__ import absolute_import
from django.db.models.sql.datastructures import EmptyResultSet
from django.db.models.sql.subqueries import *
from django.db.models.sql.query import *
from django.db.models.sql.where import AND, OR
__all__ = ['Query', 'AND', 'OR', 'EmptyResultSet']
__all__ = ['Query', 'AND', 'OR', 'EmptyResultSet']

View File

@ -10,8 +10,10 @@ TODO:
"This form field requires foo.js" and form.js_includes()
"""
from __future__ import absolute_import
from django.core.exceptions import ValidationError
from widgets import *
from fields import *
from forms import *
from models import *
from django.forms.fields import *
from django.forms.forms import *
from django.forms.models import *
from django.forms.widgets import *

View File

@ -1 +1,3 @@
from widgets import *
from __future__ import absolute_import
from django.forms.extras.widgets import *

View File

@ -1,3 +1,5 @@
from __future__ import absolute_import
import datetime
import os
import re
@ -109,14 +111,14 @@ class CompatCookie(SimpleCookie):
warnings.warn("CompatCookie is deprecated, use django.http.SimpleCookie instead.",
DeprecationWarning)
from django.utils.datastructures import MultiValueDict, ImmutableList
from django.utils.encoding import smart_str, iri_to_uri, force_unicode
from django.utils.http import cookie_date
from django.http.multipartparser import MultiPartParser
from django.conf import settings
from django.core import signing
from django.core.files import uploadhandler
from utils import *
from django.http.multipartparser import MultiPartParser
from django.http.utils import *
from django.utils.datastructures import MultiValueDict, ImmutableList
from django.utils.encoding import smart_str, iri_to_uri, force_unicode
from django.utils.http import cookie_date
RESERVED_CHARS="!*'();:@&=+$,/?%#[]"