Skip to content

Commit

Permalink
Separate column type parsing into usertypes
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepyLeslie committed Jul 8, 2024
1 parent 421eafb commit e73f0dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 2 additions & 6 deletions sandbox/grist/dropdown_condition.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import usertypes

from predicate_formula import NamedEntity, parse_predicate_formula_json, TreeConverter
import predicate_formula
Expand Down Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions sandbox/grist/usertypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit e73f0dc

Please sign in to comment.