Update maxheight field to be a string
This commit is contained in:
parent
ab48059387
commit
29417ca4e8
4 changed files with 25 additions and 4 deletions
|
@ -17,7 +17,7 @@ ECO_REGION_ADJUSTMENTS = {
|
|||
# Relevant columns and information used to retrieve information from the spreadsheet
|
||||
PLANT_COLS = {
|
||||
'SCIENTIFIC NAME': {"str": "name", "expected_type": str, "max_length": 50},
|
||||
'MAX HT': {"str": "maxheight", "expected_type": float},
|
||||
'MAX HT': {"str": "maxheight", "expected_type": str},
|
||||
'SPACING': {"str": "spacing", "expected_type": float},
|
||||
'COMMON NAME': {"str": "commonname", "expected_type": str, "null_allowed": True, "max_length": 200},
|
||||
'SYNONYM': {"str": "synonym", "expected_type": str, "null_allowed": True, "max_length": 200},
|
||||
|
|
|
@ -56,6 +56,9 @@ def get_plant_json_from_row(row_data):
|
|||
row_data[field_index], SOIL_ORDER_PK_MAPPING)
|
||||
plant_json_fields[model_field_name] = soil_orders_list
|
||||
|
||||
elif field_str == "maxheight":
|
||||
plant_json_fields[model_field_name] = str(row_data[field_index])
|
||||
|
||||
elif field_str in {'wet', 'mesic', 'dry'}:
|
||||
if row_data[field_index] != None:
|
||||
soil_variant_pk = SOIL_VARIANT_PK_MAPPING[field.capitalize()]
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.8 on 2021-12-07 01:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('api', '0010_christchurchregion'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='plant',
|
||||
name='maxheight',
|
||||
field=models.CharField(max_length=20),
|
||||
),
|
||||
]
|
|
@ -100,7 +100,7 @@ class Zone(models.Model):
|
|||
class Plant(models.Model):
|
||||
name = models.CharField(unique=True, max_length=50)
|
||||
commonname = models.CharField(null=True, blank=True, max_length=200)
|
||||
maxheight = models.FloatField()
|
||||
maxheight = models.CharField(max_length=20)
|
||||
spacing = models.FloatField()
|
||||
synonym = models.CharField(null=True, blank=True, max_length=200)
|
||||
water_tolerance = models.ForeignKey(
|
||||
|
@ -121,7 +121,7 @@ class Plant(models.Model):
|
|||
|
||||
@property
|
||||
def forest_position(self):
|
||||
return self.zones.all().filter(name="BUSH PROFILE POSITION", variant__in={"Core", "Border", "Skin"}).values('variant')
|
||||
return self.zones.all().filter(name="BUSH PROFILE POSITION", variant__in={"Core", "Border", "Skin", "Epiphytes"}).values('variant')
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
|
@ -133,7 +133,7 @@ class Plant(models.Model):
|
|||
def display_growth_form(self):
|
||||
growth_form_str = f'{str(self.growth_form)} / ' if self.growth_form is not None else ''
|
||||
forest_position_values_str = ', '.join([position['variant'][0] for position in self.forest_position])
|
||||
forest_position_str = f' / {forest_position_values_str}' if self.forest_position is not None else ''
|
||||
forest_position_str = f' / {forest_position_values_str}' if len(self.forest_position) != 0 else ''
|
||||
return f"{growth_form_str}{self.maxheight} / {self.spacing}{forest_position_str}"
|
||||
|
||||
@property
|
||||
|
|
Loading…
Reference in a new issue