From e73f0dc14d1c969c349e3c8144cda270ba8ffe43 Mon Sep 17 00:00:00 2001 From: "Leslie H." Date: Mon, 8 Jul 2024 16:13:41 -0400 Subject: [PATCH] Separate column type parsing into usertypes --- sandbox/grist/dropdown_condition.py | 8 ++------ sandbox/grist/usertypes.py | 7 +++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sandbox/grist/dropdown_condition.py b/sandbox/grist/dropdown_condition.py index a031d4b4f5..30ef271dbf 100644 --- a/sandbox/grist/dropdown_condition.py +++ b/sandbox/grist/dropdown_condition.py @@ -1,5 +1,6 @@ import json import logging +import usertypes from predicate_formula import NamedEntity, parse_predicate_formula_json, TreeConverter import predicate_formula @@ -38,12 +39,7 @@ def perform_dropdown_condition_renames(useractions, renames): continue # Find out what table this column refers to and belongs to. - if col.type.startswith("Ref:"): - ref_table_id = col.type[4:] - elif col.type.startswith("RefList:"): - ref_table_id = col.type[8:] - else: - ref_table_id = None + ref_table_id = usertypes.get_referenced_table_id(col.type) self_table_id = col.parentId.tableId def renamer(subject): diff --git a/sandbox/grist/usertypes.py b/sandbox/grist/usertypes.py index d617b927f7..d599a22273 100644 --- a/sandbox/grist/usertypes.py +++ b/sandbox/grist/usertypes.py @@ -63,6 +63,13 @@ def wrapper(method): return method return wrapper +def get_referenced_table_id(col_type): + if col_type.startswith("Ref:"): + return col_type[4:] + if col_type.startswith("RefList:"): + return col_type[8:] + return None + def ifError(value, value_if_error): """