blob: f3957e79f08c0d72852115cd9f81f01a3cbd55f9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
from typing import Any
from django.contrib.auth.mixins import LoginRequiredMixin
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
people = org.person_set.all()
context['people'] = people
return context
|