aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/core/views.py
blob: a40f945b7ab07b7f36f32c7857dec6bc0b3c6659 (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
28
from django.contrib.auth.decorators import login_required
from django.shortcuts import render

from ctrack.organisations.models import IncidentReport, Organisation
from ctrack.register.models import EngagementEvent


def home_page(request):
    if request.user.is_stakeholder:
        org = Organisation.objects.get(
            name=request.user.stakeholder.person.get_organisation_name()
        )
        irs = IncidentReport.objects.filter(organisation__name=org)
        systems = org.applicable_systems()
        peoples = org.person_set.all()
        engagement_events = EngagementEvent.objects.filter(participants__in=peoples)
        return render(
            request,
            "pages/stakeholder_home.html",
            context={
                "org": org,
                "systems": systems,
                "irs": irs,
                "engagement_events": engagement_events,
            },
        )
    else:
        return render(request, "pages/home.html")