### ===================================================================================================================
### FUNTION: Get data for the beoordelings report
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from typing import TYPE_CHECKING
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
from viiapackage.database.viia_myviia_get_info import myviia_get_object_deel
### ===================================================================================================================
### 2. Helper function
### ===================================================================================================================
[docs]def get_beoordeling_data(project: ViiaProject) -> dict:
"""
This function will generate dictionary keys for beoordeling data that can later be used as jinja tags for
templating.
.. note:: Currently only available in Dutch.
Input
- project (obj): VIIA project object containing collections of fem objects and project variables.
Output
- Dictionary of jinja tags assigned to corresponding info.
"""
context = {}
# collect opname images location
# Obtain object part opname
objectpart_id = None
for objectpart in project.project_information['objectdelen']:
if objectpart['naam'] == project.project_information['objectdeel']:
objectpart_id = objectpart['id']
break
if not objectpart_id:
raise ValueError("ERROR: Could not find the correct objectpart.")
object_part_details = myviia_get_object_deel(object_deel_id=objectpart_id, token=project.token)
if project.project_information['inspection_type'] in ['TYPO', 'LOOV', 'EVS2']:
project.project_information['object_deel_opname'] = object_part_details['object_deel_opname']
project.project_information['opname_images_folder'] = 'opname_images'
elif project.project_information['inspection_subtype'] in ['VAL', 'VAL-P']:
project.project_information['object_deel_opname'] = object_part_details['object_deel_opname_val']
project.project_information['opname_images_folder'] = 'opname_val_images'
elif project.project_information['inspection_subtype'] in ['VAL-C']:
project.project_information['object_deel_opname'] = object_part_details['object_deel_opname_val2']
project.project_information['opname_images_folder'] = 'opname_val2_images'
# Conclusion of analysis
context['conclusie_analyse'] = project.project_information['conclusie_analyse']
# If the object is Praktijkaanpak, we need to know the expected type of strengthening for the objectpart.
context['categorie_versterking'] = 'Te bepalen'
categorieversterkingmap = {
0: 'op norm',
1: 'klein',
2: 'gemiddeld',
3: 'zwaar'}
for object_deel in project.project_information['objectdelen']:
if object_deel['naam'] == project.project_information['objectdeel'] and 'categorie_versterking' in object_deel\
and object_deel['categorie_versterking'] is not None:
context['categorie_versterking'] = categorieversterkingmap[object_deel['categorie_versterking']]
break
# Find adjective to use in report
if project.project_information['building_type_simple'] == 'woning':
context['adj_building_type_simple'] = 'de'
else:
context['adj_building_type_simple'] = 'het'
return context
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================