Skip to content

Commit 4f4921a

Browse files
committed
Get rank by column name
1 parent eeee9d4 commit 4f4921a

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

specifyweb/backend/trees/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,14 @@ def add_default_tree_record(tree_type: str, discipline, row: dict, tree_name: st
176176
if v:
177177
defaults[model_field] = v
178178

179+
# Get the rank by the column name.
180+
# It should already exist by this point, but worst case it will be generated here.
179181
treedef_item, _ = tree_rank_model.objects.get_or_create(
180182
name=rank,
181183
treedef=tree_def,
182-
rankid=rank_id,
183184
defaults={
184-
'title': rank.capitalize()
185+
'title': rank.capitalize(),
186+
'rankid': rank_id
185187
}
186188
)
187189

@@ -343,7 +345,7 @@ def lines_iter() -> Iterator[str]:
343345

344346
logger.debug(f"Creating default tree with the following {rank_count} ranks:")
345347
logger.debug(rank_names_lst)
346-
348+
347349
tree_name = initialize_default_tree(tree_type, discipline, initial_tree_name, rank_names_lst)
348350
set_tree(tree_name)
349351

specifyweb/backend/trees/views.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,19 +648,19 @@ def has_tree_read_permission(tree: TREE_TABLE) -> bool:
648648
},
649649
"required": ["url", "disciplineName"],
650650
"oneOf": [
651-
{"required": ["mapping"],
652-
"properties": {
653-
"mapping": {
654-
"type": "object",
655-
"description": "An object describing the column mapping of the CSV data."
656-
},
657-
}},
658651
{"required": ["mappingUrl"],
659652
"properties": {
660653
"mappingUrl": {
661654
"type": "string",
662655
"description": "The URL of a JSON file describing the column mapping of the CSV data."
663656
},
657+
}},
658+
{"required": ["mapping"],
659+
"properties": {
660+
"mapping": {
661+
"type": "object",
662+
"description": "An object describing the column mapping of the CSV data."
663+
},
664664
}}
665665
]
666666
},

0 commit comments

Comments
 (0)