59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
|
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):
|
||
|
cons_office = get_object_or_404(
|
||
|
KonovaCode,
|
||
|
id=id,
|
||
|
)
|
||
|
cons_interventions = Intervention.objects.filter(
|
||
|
responsible__conservation_office__id=id,
|
||
|
deleted=None,
|
||
|
)
|
||
|
cons_comps = Compensation.objects.filter(
|
||
|
intervention__in=cons_interventions,
|
||
|
deleted=None,
|
||
|
)
|
||
|
cons_eco_account = EcoAccount.objects.filter(
|
||
|
responsible__conservation_office__id=id,
|
||
|
deleted=None,
|
||
|
)
|
||
|
|
||
|
report = TimespanReport(id)
|
||
|
|
||
|
template = "analysis/reports/detail.html"
|
||
|
context = {
|
||
|
"office": cons_office,
|
||
|
"report": report,
|
||
|
}
|
||
|
context = BaseContext(request, context).context
|
||
|
return render(request, template, context)
|