diff options
Diffstat (limited to '')
-rw-r--r-- | ctrack/caf/managers.py | 25 | ||||
-rw-r--r-- | ctrack/caf/models.py | 3 | ||||
-rw-r--r-- | ctrack/organisations/tests/factories.py | 2 | ||||
-rw-r--r-- | ctrack/static/css/project.css | 30 | ||||
-rw-r--r-- | ctrack/static/css/project.css.map | 8 |
5 files changed, 50 insertions, 18 deletions
diff --git a/ctrack/caf/managers.py b/ctrack/caf/managers.py new file mode 100644 index 0000000..3aea117 --- /dev/null +++ b/ctrack/caf/managers.py @@ -0,0 +1,25 @@ +from django.db import models + +from ctrack.organisations.models import Organisation, Person + + +class ApplicableSystemManager(models.Manager): + def with_primary_contact(self): + """ + Add in the name of the primary nis contact to the context. + Using Custom Managers Django docs for an example. + """ + from django.db import connection + with connection.cursor() as cursor: + cursor.execute(""" + SELECT a.id, a.name, o.id, c.id, sm.descriptor, p.id, o.name + FROM caf_applicablesystem a, organisations_organisation o, organisations_person p, caf_caf c, organisations_submode sm + WHERE a.organisation_id = o.id AND a.caf_id = c.id AND p.organisation_id = o.id AND o.submode_id = sm.id AND p.primary_nis_contact = False; + """) + result_list = [] + for row in cursor.fetchall(): + org = Organisation.objects.get(pk=row[2]) + ass = self.model(id=row[0], name=row[1], organisation=org) + ass.nis_contact = Person.objects.get(pk=row[5]) + result_list.append(ass) + return result_list diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py index 2069612..a031657 100644 --- a/ctrack/caf/models.py +++ b/ctrack/caf/models.py @@ -1,5 +1,6 @@ from django.db import models +from ctrack.caf.managers import ApplicableSystemManager from ctrack.organisations.models import Organisation, Person @@ -55,6 +56,8 @@ class ApplicableSystem(models.Model): class Meta: verbose_name = "Applicable System" + objects = ApplicableSystemManager() + def __str__(self): return f"{self.organisation.name} | {self.name}" diff --git a/ctrack/organisations/tests/factories.py b/ctrack/organisations/tests/factories.py index fd8ad88..38e6079 100644 --- a/ctrack/organisations/tests/factories.py +++ b/ctrack/organisations/tests/factories.py @@ -81,7 +81,7 @@ class PersonFactory(DjangoModelFactory): if extracted: self.role.add(extracted) - primary_nis_contact = True + primary_nis_contact = factory.LazyFunction(lambda : random.choice([True, False])) voluntary_point_of_contact = True has_egress = False title = factory.LazyFunction(lambda: random.randint(1, 8)) diff --git a/ctrack/static/css/project.css b/ctrack/static/css/project.css index e2ff1d0..312ff2d 100644 --- a/ctrack/static/css/project.css +++ b/ctrack/static/css/project.css @@ -1,44 +1,54 @@ .alert-debug { background-color: #fff; border-color: #d6e9c6; - color: #000; } + color: #000; +} .alert-error { background-color: #f2dede; border-color: #eed3d7; - color: #b94a48; } + color: #b94a48; +} .bg-light { - background-color: green; } + background-color: green; +} .btn:hover { background-color: red; - border-color: orange; } + border-color: orange; +} .container a { color: darkslategrey; background-color: yellowgreen; - font-size: large; } + font-size: large; +} #chunky { border: 8px dashed yellowgreen; border-radius: 10px; - box-shadow: 3px 10px 12px lightgray; } + box-shadow: 3px 10px 12px lightgray; +} .tabaligncenter { - text-align: center; } + text-align: center; +} .table-sm tr { font-size: 0.75rem; line-height: 12px; - min-height: 10px; } + min-height: 10px; +} .textinput { background-color: lightgoldenrodyellow; box-shadow: 2px 10px 15px lightgray; - height: 49px; } + height: 49px; +} #_title { - color: orangered; } + color: orangered; +} /*# sourceMappingURL=project.css.map */ diff --git a/ctrack/static/css/project.css.map b/ctrack/static/css/project.css.map index 2a1418f..6c969b7 100644 --- a/ctrack/static/css/project.css.map +++ b/ctrack/static/css/project.css.map @@ -1,7 +1 @@ -{ -"version": 3, -"mappings": "AA2BA,YAAa;EACX,gBAAgB,EAhBV,IAAI;EAiBV,YAAY,EAhBD,OAAO;EAiBlB,KAAK,EAhBC,IAAI;;AAmBZ,YAAa;EACX,gBAAgB,EAnBX,OAAO;EAoBZ,YAAY,EAnBF,OAAO;EAoBjB,KAAK,EAnBD,OAAO;;AAsBb,SAAU;EACR,gBAAgB,EAAE,KAAK;;AAGzB,UAAW;EACT,gBAAgB,EAAE,GAAG;EACrB,YAAY,EAAE,MAAM;;AAGtB,YAAa;EACX,KAAK,EAAE,aAAa;EACpB,gBAAgB,EAAE,WAAW;EAC7B,SAAS,EAAE,KAAK;;AAGlB,OAAQ;EACN,MAAM,EAAE,sBAAsB;EAC9B,aAAa,EAAE,IAAI;EACnB,UAAU,EAAE,uBAAuB;;AAGrC,eAAgB;EACd,UAAU,EAAE,MAAM;;AAGpB,YAAa;EACX,SAAS,EAAE,OAAO;EAClB,WAAW,EAAE,IAAI;EACjB,UAAU,EAAE,IAAI;;AAGlB,UAAW;EACT,gBAAgB,EAAE,oBAAoB;EACtC,UAAU,EAAE,uBAAuB;EACnC,MAAM,EAvDO,IAAI;;AA0DnB,OAAQ;EACN,KAAK,EAAE,SAAS", -"sources": ["../sass/project.scss"], -"names": [], -"file": "project.css" -} +{"version":3,"sourceRoot":"","sources":["../sass/project.scss"],"names":[],"mappings":"AA2BA;EACE,kBAhBM;EAiBN,cAhBW;EAiBX,OAhBM;;;AAmBR;EACE,kBAnBK;EAoBL,cAnBU;EAoBV,OAnBI;;;AAsBN;EACE;;;AAGF;EACE;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA,QAvDa;;;AA0Df;EACE","file":"project.css"}
\ No newline at end of file |