| 1 |
# -*- coding: utf-8 -*- |
|---|
| 2 |
from django.db import models |
|---|
| 3 |
from django.utils.translation import ugettext_lazy as _ |
|---|
| 4 |
|
|---|
| 5 |
CONTINENTS = ( |
|---|
| 6 |
('AF', _('Africa')), |
|---|
| 7 |
('NA', _('North America')), |
|---|
| 8 |
('EU', _('Europe')), |
|---|
| 9 |
('AS', _('Asia')), |
|---|
| 10 |
('OC', _('Oceania')), |
|---|
| 11 |
('SA', _('South America')), |
|---|
| 12 |
('AN', _('Antarctica')) |
|---|
| 13 |
) |
|---|
| 14 |
|
|---|
| 15 |
AREAS = ( |
|---|
| 16 |
('a', _('Another')), |
|---|
| 17 |
('i', _('Island')), |
|---|
| 18 |
('ar', _('Arrondissement')), |
|---|
| 19 |
('at', _('Atoll')), |
|---|
| 20 |
('ai', _('Autonomous island')), |
|---|
| 21 |
('ca', _('Canton')), |
|---|
| 22 |
('cm', _('Commune')), |
|---|
| 23 |
('co', _('County')), |
|---|
| 24 |
('dp', _('Department')), |
|---|
| 25 |
('de', _('Dependency')), |
|---|
| 26 |
('dt', _('District')), |
|---|
| 27 |
('dv', _('Division')), |
|---|
| 28 |
('em', _('Emirate')), |
|---|
| 29 |
('gv', _('Governorate')), |
|---|
| 30 |
('ic', _('Island council')), |
|---|
| 31 |
('ig', _('Island group')), |
|---|
| 32 |
('ir', _('Island region')), |
|---|
| 33 |
('kd', _('Kingdom')), |
|---|
| 34 |
('mu', _('Municipality')), |
|---|
| 35 |
('pa', _('Parish')), |
|---|
| 36 |
('pf', _('Prefecture')), |
|---|
| 37 |
('pr', _('Province')), |
|---|
| 38 |
('rg', _('Region')), |
|---|
| 39 |
('rp', _('Republic')), |
|---|
| 40 |
('sh', _('Sheading')), |
|---|
| 41 |
('st', _('State')), |
|---|
| 42 |
('sd', _('Subdivision')), |
|---|
| 43 |
('sj', _('Subject')), |
|---|
| 44 |
('ty', _('Territory')), |
|---|
| 45 |
) |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
class Country(models.Model): |
|---|
| 50 |
""" |
|---|
| 51 |
International Organization for Standardization (ISO) 3166-1 Country list |
|---|
| 52 |
""" |
|---|
| 53 |
iso2_code = models.CharField(_('ISO alpha-2'), max_length=2, unique=True) |
|---|
| 54 |
name = models.CharField(_('Official name (CAPS)'), max_length=128) |
|---|
| 55 |
printable_name = models.CharField(_('Country name'), max_length=128) |
|---|
| 56 |
iso3_code = models.CharField(_('ISO alpha-3'), max_length=3, unique=True) |
|---|
| 57 |
numcode = models.PositiveSmallIntegerField(_('ISO numeric'), null=True, blank=True) |
|---|
| 58 |
active = models.BooleanField(_('Country is active'), default=True) |
|---|
| 59 |
continent = models.CharField(_('Continent'), choices=CONTINENTS, max_length=2) |
|---|
| 60 |
admin_area = models.CharField(_('Administrative Area'), choices=AREAS, max_length=2, null=True, blank=True) |
|---|
| 61 |
|
|---|
| 62 |
class Meta: |
|---|
| 63 |
verbose_name = _('Country') |
|---|
| 64 |
verbose_name_plural = _('Countries') |
|---|
| 65 |
ordering = ('name',) |
|---|
| 66 |
|
|---|
| 67 |
def __unicode__(self): |
|---|
| 68 |
return self.printable_name |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
class AdminArea(models.Model): |
|---|
| 72 |
""" |
|---|
| 73 |
Administrative Area level 1 for a country. For the US, this would be the states |
|---|
| 74 |
""" |
|---|
| 75 |
country = models.ForeignKey(Country) |
|---|
| 76 |
name = models.CharField(_('Admin Area name'), max_length=60, ) |
|---|
| 77 |
abbrev = models.CharField(_('Postal Abbreviation'), max_length=3, null=True, blank=True) |
|---|
| 78 |
active = models.BooleanField(_('Area is active'), default=True) |
|---|
| 79 |
|
|---|
| 80 |
class Meta: |
|---|
| 81 |
verbose_name = _('Administrative Area') |
|---|
| 82 |
verbose_name_plural = _('Administrative Areas') |
|---|
| 83 |
ordering = ('name',) |
|---|
| 84 |
|
|---|
| 85 |
def __unicode__(self): |
|---|
| 86 |
return self.name |
|---|