diff --git a/backend/right_tree/api/management/commands/_spreadsheet_constants.py b/backend/right_tree/api/management/commands/_spreadsheet_constants.py index 6ffbaa5..6096508 100644 --- a/backend/right_tree/api/management/commands/_spreadsheet_constants.py +++ b/backend/right_tree/api/management/commands/_spreadsheet_constants.py @@ -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}, diff --git a/backend/right_tree/api/management/commands/createplantfixtures.py b/backend/right_tree/api/management/commands/createplantfixtures.py index f34d15e..fc759cc 100644 --- a/backend/right_tree/api/management/commands/createplantfixtures.py +++ b/backend/right_tree/api/management/commands/createplantfixtures.py @@ -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()] diff --git a/backend/right_tree/api/migrations/0011_alter_plant_maxheight.py b/backend/right_tree/api/migrations/0011_alter_plant_maxheight.py new file mode 100644 index 0000000..e95b64f --- /dev/null +++ b/backend/right_tree/api/migrations/0011_alter_plant_maxheight.py @@ -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), + ), + ] diff --git a/backend/right_tree/api/models.py b/backend/right_tree/api/models.py index 1c8d713..58da42a 100644 --- a/backend/right_tree/api/models.py +++ b/backend/right_tree/api/models.py @@ -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