2021-10-18 15:52:51 +02:00
|
|
|
from django.contrib.auth.decorators import login_required
|
|
|
|
from django.http import HttpRequest
|
|
|
|
from django.shortcuts import render, get_object_or_404
|
|
|
|
|
|
|
|
from analysis.utils.report import TimespanReport
|
|
|
|
from codelist.models import KonovaCode
|
|
|
|
from konova.contexts import BaseContext
|
|
|
|
from konova.decorators import conservation_office_group_required
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
@conservation_office_group_required
|
|
|
|
def index_reports_view(request: HttpRequest):
|
|
|
|
"""
|
|
|
|
|
|
|
|
Args:
|
|
|
|
request (HttpRequest): The incoming request
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
"""
|
|
|
|
template = "analysis/reports/index.html"
|
|
|
|
context = {}
|
|
|
|
context = BaseContext(request, context).context
|
|
|
|
return render(request, template, context)
|
|
|
|
|
|
|
|
|
|
|
|
def detail_report_view(request: HttpRequest, id: str):
|
2021-10-19 14:22:41 +02:00
|
|
|
""" Renders the detailed report for a conservation office
|
|
|
|
|
|
|
|
Args:
|
|
|
|
request (HttpRequest): The incoming request
|
|
|
|
id (str): The conservation_office KonovaCode id
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
"""
|
2021-10-18 15:52:51 +02:00
|
|
|
cons_office = get_object_or_404(
|
|
|
|
KonovaCode,
|
|
|
|
id=id,
|
|
|
|
)
|
|
|
|
report = TimespanReport(id)
|
|
|
|
|
|
|
|
template = "analysis/reports/detail.html"
|
|
|
|
context = {
|
|
|
|
"office": cons_office,
|
|
|
|
"report": report,
|
|
|
|
}
|
|
|
|
context = BaseContext(request, context).context
|
|
|
|
return render(request, template, context)
|