diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-16 10:22:02 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-16 10:22:02 +0100 |
commit | 2b11d0e43378c27b250e93e91b9bdc10346af44e (patch) | |
tree | dccbd0cd42e2400e3fa5fb363ab9fcd3616f9393 /ctrack | |
parent | 7637504292d8fd183af8f4bcbb968fc1b69cd8f7 (diff) |
added basic lead and deputy inspector to organisation model
Diffstat (limited to 'ctrack')
7 files changed, 68 insertions, 7 deletions
diff --git a/ctrack/organisations/migrations/0002_auto_20201015_1955.py b/ctrack/organisations/migrations/0002_auto_20201015_1955.py new file mode 100644 index 0000000..dcc2463 --- /dev/null +++ b/ctrack/organisations/migrations/0002_auto_20201015_1955.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.2 on 2020-10-15 19:55 + +import ctrack.organisations.models +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('organisations', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='organisation', + name='deputy_lead_inspector', + field=models.ForeignKey(null=True, on_delete=models.SET(ctrack.organisations.models.Organisation.get_sentinel_user), related_name='deputy_inspector', to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='organisation', + name='lead_inspector', + field=models.ForeignKey(null=True, on_delete=models.SET(ctrack.organisations.models.Organisation.get_sentinel_user), related_name='lead_inspector', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py index 90d6f88..f884d39 100644 --- a/ctrack/organisations/models.py +++ b/ctrack/organisations/models.py @@ -136,6 +136,8 @@ class Organisation(models.Model): designation_type = models.IntegerField(choices=DESIGNATION_TYPE, default=1) registered_company_name = models.CharField(max_length=255, blank=True) registered_company_number = models.CharField(max_length=100, blank=True) + lead_inspector = models.ForeignKey("users.User", blank=False, null=True, on_delete=models.SET(get_sentinel_user), related_name="lead_inspector") + deputy_lead_inspector = models.ForeignKey("users.User", blank=False, null=True, on_delete=models.SET(get_sentinel_user), related_name="deputy_inspector") date_updated = models.DateField(auto_now=True) # updated_by = models.ForeignKey( # get_user_model(), on_delete=models.SET(get_sentinel_user) diff --git a/ctrack/organisations/templates/organisations/organisation_detail.html b/ctrack/organisations/templates/organisations/organisation_detail.html index eff4dd3..82c802f 100644 --- a/ctrack/organisations/templates/organisations/organisation_detail.html +++ b/ctrack/organisations/templates/organisations/organisation_detail.html @@ -46,6 +46,14 @@ <td><span class="text-danger">No</span></td> {% endif %} </tr> + <tr> + <td class="w-25"><strong>Lead Inspector:</strong></td> + <td>{{ object.lead_inspector.name }}</td> + </tr> + <tr> + <td class="w-25"><strong>Deputy Lead Inspector:</strong></td> + <td>{{ object.deputy_lead_inspector.name }}</td> + </tr> <tr> <td class="w-25"><strong>Registered Company Name:</strong></td> <td>{{ object.registered_company_name }}</td> @@ -84,7 +92,7 @@ {% if applicable_systems|length > 0 %} {% for es in essential_services %} <tr> - <td style="width: 30%"><a + <td class="w-25"<a href="{% url "organisations:essential_service_detail" es.pk %}">{{ es.name }}</a> </td> <td>{{ es.description }} @@ -114,7 +122,7 @@ {% if applicable_systems|length > 0 %} {% for ass in applicable_systems %} <tr> - <td><a href="{% url "caf:ass_detail" ass.id %}">{{ ass.name }}</a></td> + <td class="w-25"><a href="{% url "caf:ass_detail" ass.id %}">{{ ass.name }}</a></td> <td>{{ ass.function }} </td> </tr> diff --git a/ctrack/organisations/templates/organisations/organisation_list.html b/ctrack/organisations/templates/organisations/organisation_list.html index c282bce..661a0d4 100644 --- a/ctrack/organisations/templates/organisations/organisation_list.html +++ b/ctrack/organisations/templates/organisations/organisation_list.html @@ -35,7 +35,7 @@ <tr> <td><a href="{% url "organisations:detail" org.slug %}">{{ org.name }}</a></td> <td>{{ org.submode }}</td> - <td>LEAD INSPECTOR</td> + <td>{{ org.lead_inspector }}</td> <td> {% if org.primary_contacts %} <ul style="list-style-type:none; float:left; padding: 0"> diff --git a/ctrack/organisations/tests/factories.py b/ctrack/organisations/tests/factories.py index 17539f2..c8340b9 100644 --- a/ctrack/organisations/tests/factories.py +++ b/ctrack/organisations/tests/factories.py @@ -3,10 +3,11 @@ from datetime import datetime import factory from django.contrib.auth import get_user_model -from factory.django import DjangoModelFactory from factory import Faker, SubFactory, post_generation +from factory.django import DjangoModelFactory from ctrack.organisations.models import Address, Organisation, Person, Role +from ctrack.users.tests.factories import UserFactory User = get_user_model() @@ -43,6 +44,8 @@ class OrganisationFactory(DjangoModelFactory): oes = factory.LazyFunction(lambda: random.choice([True, False])) registered_company_name = Faker("company") registered_company_number = Faker("numerify", text="######") + lead_inspector = factory.SubFactory(UserFactory) + deputy_lead_inspector = factory.SubFactory(UserFactory) date_updated = Faker("date_this_year", before_today=True) comments = Faker("paragraph", nb_sentences=3) active = True diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py index 108d0ce..adb61d9 100644 --- a/ctrack/organisations/tests/test_models.py +++ b/ctrack/organisations/tests/test_models.py @@ -1,18 +1,21 @@ import random import pytest - from slugify import slugify -from ctrack.organisations.models import IncidentReport, Organisation from ctrack.caf.models import CAF, Grading -from ctrack.caf.tests.factories import ApplicableSystemFactory from ctrack.caf.models import EssentialService +from ctrack.caf.tests.factories import ApplicableSystemFactory from ctrack.core.utils import fnames pytestmark = pytest.mark.django_db +def test_lead_deputy_inspector(org): + assert org.lead_inspector + assert org.deputy_lead_inspector + + def test_organisation_get_absolute_url(org): slug = slugify(org.name) assert org.get_absolute_url() == f"/organisations/{slug}/" diff --git a/ctrack/register/migrations/0003_auto_20201015_1955.py b/ctrack/register/migrations/0003_auto_20201015_1955.py new file mode 100644 index 0000000..58d11c1 --- /dev/null +++ b/ctrack/register/migrations/0003_auto_20201015_1955.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.2 on 2020-10-15 19:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisations', '0002_auto_20201015_1955'), + ('register', '0002_auto_20201014_1605'), + ] + + operations = [ + migrations.AlterField( + model_name='singledatetimeevent', + name='participants', + field=models.ManyToManyField(blank=True, to='organisations.Person'), + ), + ] |