Hi,
My app is used to create a report for multiple images. The strucutre of my app is:
app
βββ image_entity
ββββ __init__.py
ββββ controller.py
βββ report_editor
ββββ __init__.py
ββββ controller.py
ββββ parametrization.py
ββββ logic.py
Before entering my app you upload these images as entities.This is done because after creating a report I want these images to be deleted. Within image_entity.controller there is this function store some infomation from the images:
image_table = []
image_options = []
class ImageController(ViktorController):
''' Controller class for the image entity '''
label = "image_entity"
@ParamsFromFile(file_types=['.png', '.jpg', '.jpeg'])
def process_file(self, file: File, **kwargs) -> dict:
image_dict = {}
image_dict['image_name'] = kwargs['entity_name']
image_dict['description'] = ''
image_table.append(image_dict)
image_options.append(kwargs['entity_name'])
parent_entity = API().get_entity(kwargs['entity_id']).parent()
parent_entity.last_saved_params['create_report_step']['report_table'] = image_table
return {"create_report_step":{"report_table": image_table}}
I want to use the infomation from these images to set the values of the parameters within the report_editor. Within report_editor.parametrization I have this:
from ..image_entity.controller import image_table,image_options
def image_selection(**kwargs):
return image_options
def image_selection(**kwargs):
return image_table
class Parametrization(Parametrization):
create_report_step.image_selection = OptionField('View image', options=image_selection)
create_report_step.report_table = Table('Image descriptions',default=image_table)
Filling in the OptionField with the image_selection options works, however filling in the table does not because of this error:
Iβve tried to make the input JSON serializable by doing this:
create_report_step.report_table = Table('Image descriptions',default=list(json.dumps(image_selection())))
But this still doesnβt work.
Is there anyway to populate the table from the params gathered from the entities(images)?
Thanks,
Charlie