Skip to content

Commit

Permalink
Added more ISO fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinali1 committed Jun 7, 2016
1 parent ade88dd commit 4938938
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 9 deletions.
52 changes: 52 additions & 0 deletions countries/migrations/0005_auto_20160607_1416.py
@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-06-07 18:16
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('countries', '0004_auto_20150528_1248'),
]

operations = [
migrations.AddField(
model_name='country',
name='is_independent',
field=models.BooleanField(default=True),
preserve_default=False,
),
migrations.AddField(
model_name='country',
name='numeric_code',
field=models.PositiveSmallIntegerField(default=1),
preserve_default=False,
),
migrations.AddField(
model_name='country',
name='remark_1',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='country',
name='remark_2',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='country',
name='remark_3',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='country',
name='territory_name',
field=models.TextField(blank=True),
),
migrations.AlterField(
model_name='country',
name='name',
field=models.CharField(help_text=b'Official Country name (ISO Full name)', max_length=255, unique=True),
),
]
23 changes: 14 additions & 9 deletions countries/models.py
@@ -1,20 +1,23 @@
from django.db import models
from forex.models import Currency
from django.db.models import Count


class Country(models.Model):
"""
Represents a country, such as the US, or Mexico.
"""

name = models.CharField(max_length=255, unique=True, help_text="Official Country name")
common_name = models.CharField(max_length=255, blank=True, null=True, help_text="Common Country name")
in_name = models.CharField(max_length=255, help_text="The name of the country after the word 'in'. Useful for Autogeneration.")
name = models.CharField(max_length=255, unique=True, help_text="Official Country name (ISO Full name)")
currency = models.ManyToManyField(Currency, help_text="Official currencies for this country. More than one currency is possible")
symbol_alpha2_code = models.CharField(help_text="ISO 3166-1 alpha-2 symbol", max_length=2, unique=True)
symbol_alpha3_code = models.CharField(help_text="ISO 3166-1 alpha-3 symbol", max_length=3, blank=True, null=True)

is_independent = models.BooleanField()
numeric_code = models.PositiveSmallIntegerField()
remark_1 = models.TextField(blank=True)
remark_2 = models.TextField(blank=True)
remark_3 = models.TextField(blank=True)
territory_name = models.TextField(blank=True)

ISO_STATUS_CHOICES = (
(u'EXR', u'Exceptionally reserved'),
(u'FRU', u'Formerly used'),
Expand All @@ -23,7 +26,11 @@ class Country(models.Model):
(u'TRR', u'Transitionally reserved'),
(u'UND', u'Unassigned'),
)
iso_status = models.CharField(max_length = 3, choices = ISO_STATUS_CHOICES, default="UND")
iso_status = models.CharField(max_length=3, choices=ISO_STATUS_CHOICES, default="UND")

# Additional helpful fields
common_name = models.CharField(max_length=255, blank=True, null=True, help_text="Common Country name")
in_name = models.CharField(max_length=255, help_text="The name of the country after the word 'in'. Useful for Autogeneration.")

class Meta:
verbose_name_plural = 'Countries'
Expand Down Expand Up @@ -57,7 +64,7 @@ class City(models.Model):
Represents a city within a country
"""

name = models.CharField(max_length=255)
name = models.CharField(max_length=255)
symbol = models.CharField(max_length=255, blank=True)
country = models.ForeignKey(Country)

Expand Down Expand Up @@ -88,5 +95,3 @@ class Meta:

def __unicode__(self):
return u'%s' % (unicode(self.name))


0 comments on commit 4938938

Please sign in to comment.