Fix soil variant spreadsheet import bug where all variants added
This commit is contained in:
parent
c4fdd04e8b
commit
cb348b0f5d
1 changed files with 9 additions and 6 deletions
|
@ -66,7 +66,7 @@ PLANT_JSON_TEMPLATE = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def check_field_type(field, field_value):
|
def check_field_value(field, field_value):
|
||||||
""" Checks the validity of a feild value collected from the spreadsheet
|
""" Checks the validity of a feild value collected from the spreadsheet
|
||||||
"""
|
"""
|
||||||
expected_field_type = PLANT_COLS[field]['expected_type']
|
expected_field_type = PLANT_COLS[field]['expected_type']
|
||||||
|
@ -110,17 +110,20 @@ def get_plant_json_from_row(row_data):
|
||||||
plant_json_fields[model_field_name] = soil_orders_list
|
plant_json_fields[model_field_name] = soil_orders_list
|
||||||
|
|
||||||
elif field in {'wet', 'mesic', 'dry'}:
|
elif field in {'wet', 'mesic', 'dry'}:
|
||||||
soil_variant_pk = SOIL_VARIANT_PK_MAPPING[field.capitalize()]
|
if row_data[field_index] != None:
|
||||||
plant_json_fields[model_field_name] = plant_json_fields.get(
|
soil_variant_pk = SOIL_VARIANT_PK_MAPPING[field.capitalize()]
|
||||||
model_field_name, []) + [soil_variant_pk]
|
plant_json_fields[model_field_name] = plant_json_fields.get(
|
||||||
|
model_field_name, []) + [soil_variant_pk]
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
elif field in {'water', 'drought', 'frost', 'salinity'}:
|
elif field in {'water', 'drought', 'frost', 'salinity'}:
|
||||||
plant_json_fields[model_field_name] = TOLERANCE_PK_MAPPING[row_data[field_index]]
|
plant_json_fields[model_field_name] = TOLERANCE_PK_MAPPING[row_data[field_index]]
|
||||||
|
|
||||||
elif field in PLANT_COLS:
|
elif field in PLANT_COLS:
|
||||||
plant_json_fields[model_field_name] = row_data[field_index]
|
plant_json_fields[model_field_name] = row_data[field_index]
|
||||||
|
|
||||||
check_field_type(field, plant_json_fields[model_field_name])
|
check_field_value(field, plant_json_fields[model_field_name])
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
name_index = INFO_COL_INDEXES['name']
|
name_index = INFO_COL_INDEXES['name']
|
||||||
|
|
Loading…
Reference in a new issue