Add file_path validation in

update_frontend_node_with_template_values function
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-12-05 18:58:40 -03:00
commit d0c5d70fc6

View file

@ -1,3 +1,4 @@
from pathlib import Path
from typing import TYPE_CHECKING, List
if TYPE_CHECKING:
@ -77,8 +78,15 @@ def update_frontend_node_with_template_values(frontend_node, raw_template_data):
value = value_dict.get("value")
template_field_type = value_dict.get("type")
frontend_node_field_type = frontend_field.get("type")
file_path = value_dict.get("file_path")
if value is not None and key in frontend_template and template_field_type == frontend_node_field_type:
frontend_template[key]["value"] = value
if file_path is not None and key in frontend_template and template_field_type == frontend_node_field_type:
# check if file_path exists
if not Path(file_path).exists():
frontend_template[key]["value"] = ""
else:
frontend_template[key]["file_path"] = file_path
return frontend_node