aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/organisations/views.py')
-rw-r--r--ctrack/organisations/views.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py
index 92bb134..1ec5469 100644
--- a/ctrack/organisations/views.py
+++ b/ctrack/organisations/views.py
@@ -1,8 +1,27 @@
+from typing import Any
+
from django.contrib.auth.mixins import LoginRequiredMixin
+from django.http import HttpRequest
+from django.http import HttpResponse
from django.views.generic import DetailView
+from typing import Dict
from .models import Organisation
class OrganisationDetailView(LoginRequiredMixin, DetailView):
model = Organisation
+
+ def get_context_data(self, **kwargs: Any) -> Dict[str, Any]:
+ context = super().get_context_data()
+ org = kwargs['object']
+ no_addr = org.addresses.count()
+ if no_addr > 1:
+ context['no_addr'] = no_addr
+ addr = org.addresses.all()
+ context['addr'] = addr
+ else:
+ context['no_addr'] = 1
+ addr = org.addresses.first()
+ context['addr'] = addr
+ return context