diff options
Diffstat (limited to '')
-rw-r--r-- | ctrack/organisations/migrations/0004_auto_20200121_1027.py | 26 | ||||
-rw-r--r-- | ctrack/organisations/migrations/0005_auto_20200121_1028.py | 19 | ||||
-rw-r--r-- | ctrack/organisations/models.py | 5 | ||||
-rw-r--r-- | ctrack/organisations/tests/test_models.py | 1 |
4 files changed, 51 insertions, 0 deletions
diff --git a/ctrack/organisations/migrations/0004_auto_20200121_1027.py b/ctrack/organisations/migrations/0004_auto_20200121_1027.py new file mode 100644 index 0000000..a2e8dd1 --- /dev/null +++ b/ctrack/organisations/migrations/0004_auto_20200121_1027.py @@ -0,0 +1,26 @@ +# Generated by Django 2.2.9 on 2020-01-21 10:27 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisations', '0003_organisation_address'), + ] + + operations = [ + migrations.CreateModel( + name='AddressType', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('descriptor', models.CharField(max_length=50)), + ], + ), + migrations.AddField( + model_name='address', + name='type', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='organisations.AddressType'), + ), + ] diff --git a/ctrack/organisations/migrations/0005_auto_20200121_1028.py b/ctrack/organisations/migrations/0005_auto_20200121_1028.py new file mode 100644 index 0000000..9ee8833 --- /dev/null +++ b/ctrack/organisations/migrations/0005_auto_20200121_1028.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.9 on 2020-01-21 10:28 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisations', '0004_auto_20200121_1027'), + ] + + operations = [ + migrations.AlterField( + model_name='address', + name='type', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='organisations.AddressType'), + ), + ] diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py index 3ef794c..cf8e7de 100644 --- a/ctrack/organisations/models.py +++ b/ctrack/organisations/models.py @@ -5,7 +5,12 @@ from django.urls import reverse from slugify import slugify +class AddressType(models.Model): + descriptor = models.CharField(max_length=50) + + class Address(models.Model): + type = models.ForeignKey(AddressType, on_delete=models.CASCADE, default=1) line1 = models.CharField(max_length=255) line2 = models.CharField(max_length=255) line3 = models.CharField(max_length=255) diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py index b178508..460d3d7 100644 --- a/ctrack/organisations/tests/test_models.py +++ b/ctrack/organisations/tests/test_models.py @@ -14,3 +14,4 @@ def test_organisation_get_absolute_url(org: Organisation): def test_create_organisation(addr: Address): Organisation(name="Big Bad OES Corporation", address=addr).save() assert Organisation.objects.get(name="Big Bad OES Corporation") + assert Organisation.objects.get(name="Big Bad OES Corporation").address.type.descriptor == "Primary Address" |