From 1a9f1cf9afcecdd2f9e5fcf55ffde5a9c4d4e94e Mon Sep 17 00:00:00 2001 From: jebus Date: Thu, 28 May 2026 09:53:39 +1200 Subject: [PATCH] [Fix] Legacy API Node Depth Parsing, description validation in Reaction.create (#402) Co-authored-by: Tim Lorsbach Reviewed-on: https://git.envipath.com/enviPath/enviPy/pulls/402 --- epdb/legacy_api.py | 2 +- epdb/models.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/epdb/legacy_api.py b/epdb/legacy_api.py index 64f5f24b..fd85c65c 100644 --- a/epdb/legacy_api.py +++ b/epdb/legacy_api.py @@ -1891,7 +1891,7 @@ def add_pathway_node(request, package_uuid, pathway_uuid, n: Form[CreateNode]): pw = Pathway.objects.get(package=p, uuid=pathway_uuid) if n.nodeDepth is not None and n.nodeDepth.strip() != "": - node_depth = int(n.nodeDepth) + node_depth = int(float(n.nodeDepth)) else: node_depth = -1 diff --git a/epdb/models.py b/epdb/models.py index 1d44357c..6ff6c9bf 100644 --- a/epdb/models.py +++ b/epdb/models.py @@ -1695,7 +1695,7 @@ class Reaction( if name is not None and name.strip() != "": r.name = nh3.clean(name, tags=s.ALLOWED_HTML_TAGS).strip() - if description is not None and name.strip() != "": + if description is not None and description.strip() != "": r.description = nh3.clean(description, tags=s.ALLOWED_HTML_TAGS).strip() r.multi_step = multi_step @@ -2192,6 +2192,7 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMix depth_map = {} depth_map[0] = list() + processed = set() for n in self.nodes: num_parents = in_count[str(n.uuid)] @@ -2214,10 +2215,12 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMix unique_next_level = set() for n in level_nodes: + processed.add(n) for e in self.edges: if n in e.start_nodes.all(): for p in e.end_nodes.all(): - unique_next_level.add(p) + if p not in processed: + unique_next_level.add(p) if len(unique_next_level) > 0: depth_map[i + 1] = list(unique_next_level)