konova/analysis/views.py

50 lines
1.3 KiB
Python
Raw Normal View History

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):
""" Renders the detailed report for a conservation office
Args:
request (HttpRequest): The incoming request
id (str): The conservation_office KonovaCode id
Returns:
"""
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)