diff --git a/backend/right_tree/api/csv_utils.py b/backend/right_tree/api/csv_utils.py index fbf3575..70f83dd 100644 --- a/backend/right_tree/api/csv_utils.py +++ b/backend/right_tree/api/csv_utils.py @@ -7,8 +7,8 @@ from .utils import get_address_from_coordinates, get_point_from_coordinates CSV_FILENAME = 'plants.csv' -HEADER_FIELDS = ['Names', 'Growth form/max height (m)/spacing (m)', 'Preferred moisture regime', - 'Tolerances (Water / Drought / Frost / Salinity)', 'Ecosystem services', 'Carbon Sequestration Rate', 'Planting Stage'] +HEADER_FIELDS = ['Names', 'Growth Form / Max Height (m) / Spacing (m) / Forest Position', 'Moisture Preferences', + 'Tolerances (Water / Drought / Frost / Salinity)', 'Ecosystem Services', 'Carbon Sequestration Rate', 'Planting Stage'] def get_plant_csv_filepath(): diff --git a/backend/right_tree/api/models.py b/backend/right_tree/api/models.py index 370383e..0de2c77 100644 --- a/backend/right_tree/api/models.py +++ b/backend/right_tree/api/models.py @@ -123,6 +123,10 @@ class Plant(models.Model): soil_variants = models.ManyToManyField(SoilVariant) zones = models.ManyToManyField(Zone) + @property + def forest_position(self): + return self.zones.all().filter(name="BUSH PROFILE POSITION", variant__in={"Core", "Border", "Skin"}).values('variant') + @property def display_name(self): common_name_str = f' / {str(self.commonname)}' if self.commonname is not None else '' @@ -132,7 +136,9 @@ class Plant(models.Model): @property def display_growth_form(self): growth_form_str = f'{str(self.growth_form)} / ' if self.growth_form is not None else '' - return f"{growth_form_str}{self.maxheight} / {self.spacing}" + 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 '' + return f"{growth_form_str}{self.maxheight} / {self.spacing}{forest_position_str}" @property def moisture_preferences(self): diff --git a/backend/right_tree/api/views.py b/backend/right_tree/api/views.py index 80521c9..63519f7 100644 --- a/backend/right_tree/api/views.py +++ b/backend/right_tree/api/views.py @@ -115,5 +115,5 @@ class CSVDownloadView(viewsets.ViewSet): csv_file = open(get_plant_csv_filepath(), 'rb') response = HttpResponse(csv_file, content_type='text/csv') - response['Content-Disposition'] = 'attachment; filename="test.csv"' + response['Content-Disposition'] = 'attachment; filename="plants.csv"' return response diff --git a/frontend/src/components/steps/results/PlantList.js b/frontend/src/components/steps/results/PlantList.js index 24705f0..de0a0d8 100644 --- a/frontend/src/components/steps/results/PlantList.js +++ b/frontend/src/components/steps/results/PlantList.js @@ -78,7 +78,7 @@ TablePaginationActions.propTypes = { rowsPerPage: PropTypes.number.isRequired, }; -export default function CustomPaginationActionsTable(props) { +export default function PlantResultsTable(props) { const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(5); @@ -101,10 +101,10 @@ export default function CustomPaginationActionsTable(props) { Names - Growth form/max height (m)/spacing (m) - Preferred moisture regime - Tolerances - Ecosystem services + Growth Form / Max Height (m) / Spacing (m) / Forest Position + Moisture Preferences + Tolerances (Water / Drought / Frost / Salinity) + Ecosystem Services Carbon Sequestration Rate Planting Stage