aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ctrack/organisations/models.py3
-rw-r--r--ctrack/organisations/templates/organisations/organisation_list.html43
-rw-r--r--ctrack/organisations/urls.py5
-rw-r--r--ctrack/organisations/views.py13
-rw-r--r--ctrack/templates/base.html4
5 files changed, 62 insertions, 6 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
diff --git a/ctrack/templates/base.html b/ctrack/templates/base.html
index ff677e2..4164b06 100644
--- a/ctrack/templates/base.html
+++ b/ctrack/templates/base.html
@@ -53,10 +53,10 @@
<li class="nav-item-dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="nav-link dropdown-toggle">
- Dropdown
+ Organisations
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
- <a href="#" class="dropdown-item">Action</a>
+ <a href="#" class="dropdown-item"><a href="{% url "organisations:list" %}">Organisations</a></a>
<a href="#" class="dropdown-item">Another Action</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">Something else here</a>