diff options
Diffstat (limited to '')
-rw-r--r-- | ctrack/organisations/admin.py | 20 | ||||
-rw-r--r-- | ctrack/organisations/migrations/0011_mode_submode.py | 29 | ||||
-rw-r--r-- | ctrack/organisations/migrations/0012_organisation_submode.py | 20 | ||||
-rw-r--r-- | ctrack/organisations/migrations/0013_auto_20200125_1457.py | 19 | ||||
-rw-r--r-- | ctrack/organisations/migrations/0014_auto_20200125_1459.py | 19 | ||||
-rw-r--r-- | ctrack/organisations/models.py | 16 |
6 files changed, 118 insertions, 5 deletions
diff --git a/ctrack/organisations/admin.py b/ctrack/organisations/admin.py index 5ae61d5..019ec05 100644 --- a/ctrack/organisations/admin.py +++ b/ctrack/organisations/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import Organisation, Address, AddressType, Person, Role +from .models import Organisation, Address, AddressType, Person, Role, Mode, Submode # So we can get the organisation name - a reverse lookup @@ -9,7 +9,7 @@ def get_organisation_name(person): # We need this to ensure the column header in the admin does't read the func name -get_organisation_name.short_description = 'Organisation' +get_organisation_name.short_description = "Organisation" class AddressTypeAdmin(admin.ModelAdmin): @@ -23,21 +23,31 @@ class AddressInLine(admin.StackedInline): class OrganisationAdmin(admin.ModelAdmin): - inlines = [AddressInLine,] - list_display = ('name',) + inlines = [AddressInLine] + list_display = ("name", "submode") class PersonAdmin(admin.ModelAdmin): model = Person - list_display = ['name', get_organisation_name, 'email', 'mobile'] + list_display = ["name", get_organisation_name, "email", "mobile"] class RoleAdmin(admin.ModelAdmin): model = Role +class ModeAdmin(admin.ModelAdmin): + model = Mode + + +class SubmodeAdmin(admin.ModelAdmin): + model = Submode + + # Register your models here. admin.site.register(Organisation, OrganisationAdmin) admin.site.register(AddressType, AddressTypeAdmin) admin.site.register(Role, RoleAdmin) admin.site.register(Person, PersonAdmin) +admin.site.register(Mode, ModeAdmin) +admin.site.register(Submode, SubmodeAdmin) diff --git a/ctrack/organisations/migrations/0011_mode_submode.py b/ctrack/organisations/migrations/0011_mode_submode.py new file mode 100644 index 0000000..de7ce5c --- /dev/null +++ b/ctrack/organisations/migrations/0011_mode_submode.py @@ -0,0 +1,29 @@ +# Generated by Django 2.2.9 on 2020-01-25 14:44 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisations', '0010_auto_20200124_1629'), + ] + + operations = [ + migrations.CreateModel( + name='Mode', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('descriptor', models.CharField(max_length=100)), + ], + ), + migrations.CreateModel( + name='Submode', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('descriptor', models.CharField(max_length=100)), + ('mode', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.Mode')), + ], + ), + ] diff --git a/ctrack/organisations/migrations/0012_organisation_submode.py b/ctrack/organisations/migrations/0012_organisation_submode.py new file mode 100644 index 0000000..50d2610 --- /dev/null +++ b/ctrack/organisations/migrations/0012_organisation_submode.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.9 on 2020-01-25 14:49 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisations', '0011_mode_submode'), + ] + + operations = [ + migrations.AddField( + model_name='organisation', + name='submode', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='organisations.Submode'), + preserve_default=False, + ), + ] diff --git a/ctrack/organisations/migrations/0013_auto_20200125_1457.py b/ctrack/organisations/migrations/0013_auto_20200125_1457.py new file mode 100644 index 0000000..e39aaed --- /dev/null +++ b/ctrack/organisations/migrations/0013_auto_20200125_1457.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.9 on 2020-01-25 14:57 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisations', '0012_organisation_submode'), + ] + + operations = [ + migrations.AlterField( + model_name='organisation', + name='submode', + field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='organisations.Submode'), + ), + ] diff --git a/ctrack/organisations/migrations/0014_auto_20200125_1459.py b/ctrack/organisations/migrations/0014_auto_20200125_1459.py new file mode 100644 index 0000000..b9cb1db --- /dev/null +++ b/ctrack/organisations/migrations/0014_auto_20200125_1459.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.9 on 2020-01-25 14:59 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisations', '0013_auto_20200125_1457'), + ] + + operations = [ + migrations.AlterField( + model_name='organisation', + name='submode', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='organisations.Submode'), + ), + ] diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py index cc97a04..f602a35 100644 --- a/ctrack/organisations/models.py +++ b/ctrack/organisations/models.py @@ -35,9 +35,25 @@ class Person(models.Model): return self.organisation.name +class Mode(models.Model): + descriptor = models.CharField(max_length=100) + + def __str__(self): + return self.descriptor + + +class Submode(models.Model): + descriptor = models.CharField(max_length=100) + mode = models.ForeignKey(Mode, on_delete=models.CASCADE) + + def __str__(self): + return self.descriptor + + class Organisation(models.Model): name = models.CharField(max_length=255) slug = AutoSlugField(populate_from=['name']) + submode = models.ForeignKey(Submode, on_delete=models.CASCADE, blank=True, null=True) def get_absolute_url(self): return reverse("organisations:detail", kwargs={"slug": self.slug}) |