diff options
Diffstat (limited to 'ctrack/organisations')
-rw-r--r-- | ctrack/organisations/models.py | 3 | ||||
-rw-r--r-- | ctrack/organisations/templates/organisations/organisation_list.html | 43 | ||||
-rw-r--r-- | ctrack/organisations/urls.py | 5 | ||||
-rw-r--r-- | ctrack/organisations/views.py | 13 |
4 files changed, 60 insertions, 4 deletions
diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py index 7829b95..06ae037 100644 --- a/ctrack/organisations/models.py +++ b/ctrack/organisations/models.py @@ -141,6 +141,9 @@ class Organisation(models.Model): def __str__(self): return self.name + def primary_contacts(self): + return self.person_set.filter(primary_nis_contact=True) + class Address(models.Model): organisation = models.ForeignKey( diff --git a/ctrack/organisations/templates/organisations/organisation_list.html b/ctrack/organisations/templates/organisations/organisation_list.html new file mode 100644 index 0000000..67c62b8 --- /dev/null +++ b/ctrack/organisations/templates/organisations/organisation_list.html @@ -0,0 +1,43 @@ +{% extends "base.html" %} + +{% block content %} + <div class="container"> + + <div class="row"> + <h2>Organisations</h2> + </div> + + <div class="row"> + <div class="col-sm-12"> + <table class="table table-sm"> + <thead> + <tr> + <th>Organisation</th> + <th>Sub-mode</th> + <th>Lead Inspector</th> + <th>Point of Contact</th> + </tr> + </thead> + {% for org in organisation_list %} + <tr> + <td><a href="{% url "organisations:detail" org.slug %}">{{ org.name }}</a></td> + <td>{{ org.submode }}</td> + <td>LEAD INSPECTOR</td> + <td> + {% if org.primary_contacts %} + <ul style="list-style-type:none; float:left; padding: 0"> + {% for p in org.primary_contacts %} + <li>{{ p }} | {{ p.mobile }}</li> + {% endfor %} + </ul> + {% else %} + No contact listed + {% endif %} + </td> + </tr> + {% endfor %} + </table> + </div> + </div> + +{% endblock content %} diff --git a/ctrack/organisations/urls.py b/ctrack/organisations/urls.py index 454d73f..1ca93d8 100644 --- a/ctrack/organisations/urls.py +++ b/ctrack/organisations/urls.py @@ -1,9 +1,10 @@ from django.urls import path -from ctrack.organisations.views import OrganisationDetailView +from ctrack.organisations.views import OrganisationDetailView, OrganisationListView app_name = "organisations" urlpatterns = [ - path("<slug:slug>/", view=OrganisationDetailView.as_view(), name="detail") + path("<slug:slug>/", view=OrganisationDetailView.as_view(), name="detail"), + path("", view=OrganisationListView.as_view(), name="list") ] diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py index b085e3b..0902e57 100644 --- a/ctrack/organisations/views.py +++ b/ctrack/organisations/views.py @@ -1,12 +1,21 @@ from typing import Any +from typing import Dict from django.contrib.auth.mixins import LoginRequiredMixin -from django.views.generic import DetailView -from typing import Dict +from django.views.generic import DetailView, ListView from .models import Organisation +class OrganisationListView(LoginRequiredMixin, ListView): + model = Organisation + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["organisation_list"] = Organisation.objects.all().order_by("name") + return context + + class OrganisationDetailView(LoginRequiredMixin, DetailView): model = Organisation |