Add forest position data as part of the plant results
This commit is contained in:
parent
4745ed578a
commit
41d61ce3c5
4 changed files with 15 additions and 9 deletions
|
@ -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():
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
|||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>Names</TableCell>
|
||||
<TableCell align="right">Growth form/max height (m)/spacing (m)</TableCell>
|
||||
<TableCell align="right">Preferred moisture regime</TableCell>
|
||||
<TableCell align="right">Tolerances</TableCell>
|
||||
<TableCell align="right">Ecosystem services</TableCell>
|
||||
<TableCell align="right">Growth Form / Max Height (m) / Spacing (m) / Forest Position</TableCell>
|
||||
<TableCell align="right">Moisture Preferences</TableCell>
|
||||
<TableCell align="right">Tolerances (Water / Drought / Frost / Salinity)</TableCell>
|
||||
<TableCell align="right">Ecosystem Services</TableCell>
|
||||
<TableCell align="right">Carbon Sequestration Rate</TableCell>
|
||||
<TableCell align="right">Planting Stage</TableCell>
|
||||
</TableRow>
|
||||
|
|
Loading…
Reference in a new issue