from django.contrib.auth.decorators import login_required from django.db.models import Count, Q, Sum 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 codelist.settings import CODELIST_LAW_ID from compensation.models import EcoAccount, Compensation from ema.models import Ema from intervention.models import Intervention 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)