Fix resource generation utils
- Fixes bug where property is not found - Adds spaces to pdf so NaN is not shown
This commit is contained in:
parent
8c88f6ce6e
commit
f5629f1def
1 changed files with 18 additions and 18 deletions
|
@ -26,20 +26,21 @@ def get_plant_resource_filepath(filename=CSV_FILENAME, resource_dir='generated_r
|
|||
def get_location_filters(request):
|
||||
""" Retrives the selected location data from the request.
|
||||
"""
|
||||
filter_rows = [['LOCATION FILTERS:']]
|
||||
filter_rows = [['LOCATION FILTERS:', ' ']]
|
||||
coordinates = request.query_params.get('coordinates')
|
||||
|
||||
if coordinates is not None:
|
||||
eco_district_layer = ecological_district_coordinate_filter(
|
||||
coordinates).first()
|
||||
point = get_point_from_coordinates(coordinates)
|
||||
address = get_address_from_coordinates(coordinates)
|
||||
|
||||
filter_rows.append(['Point coordinates:', point])
|
||||
filter_rows.append(['Ecological region:', eco_district_layer.ecologic_1 or '' ])
|
||||
filter_rows.append(['Ecological district:', eco_district_layer.ecologic_2 or ' '])
|
||||
filter_rows.append(['Property address:', get_address_from_coordinates(coordinates)['full_address'] or ''])
|
||||
filter_rows.append(['Property address:', address['full_address'] if address is not None else ' '])
|
||||
else:
|
||||
filter_rows.append(["None specified"])
|
||||
filter_rows.append(["None specified", " "])
|
||||
|
||||
return filter_rows
|
||||
|
||||
|
@ -47,7 +48,7 @@ def get_location_filters(request):
|
|||
def get_soil_filters(request):
|
||||
""" Retrives the selected soil type data from the request.
|
||||
"""
|
||||
filter_rows = [['SOIL FILTERS:']]
|
||||
filter_rows = [['SOIL FILTERS:', ' ']]
|
||||
soil_variant = request.query_params.get('soilVariant')
|
||||
coordinates = request.query_params.get('coordinates')
|
||||
|
||||
|
@ -57,7 +58,7 @@ def get_soil_filters(request):
|
|||
filter_rows.append(['Soil Order:', f"{soil_order_obj.name or ' '} ({soil_order_obj.code or ' '})"])
|
||||
filter_rows.append(['Soil Variant:', soil_variant])
|
||||
else:
|
||||
filter_rows.append(["None specified"])
|
||||
filter_rows.append(["None specified", " "])
|
||||
|
||||
return filter_rows
|
||||
|
||||
|
@ -65,20 +66,19 @@ def get_soil_filters(request):
|
|||
def get_site_filters(request):
|
||||
""" Retrives the selected site data from the request.
|
||||
"""
|
||||
filter_rows = [['SITE FILTERS:']]
|
||||
filter_rows = [['SITE FILTERS:', ' ']]
|
||||
|
||||
habitat = request.query_params.get('habitat')
|
||||
zone = request.query_params.get('zone')
|
||||
if zone is not None and habitat is not None:
|
||||
habitat_json = json.loads(habitat)
|
||||
zone_json = json.loads(zone)
|
||||
|
||||
filter_rows.append(['Habitat:', habitat_json.get("name", " ")])
|
||||
filter_rows.append(['Zone Name:', zone_json.get("name", " ")])
|
||||
filter_rows.append(['Zone Variant:', zone_json.get("variant", " ")])
|
||||
filter_rows.append(['Zone Refined Variant:', zone_json.get("refined_variant", " ")])
|
||||
else:
|
||||
filter_rows.append(["None specified"])
|
||||
filter_rows.append(["None specified", " "])
|
||||
|
||||
return filter_rows
|
||||
|
||||
|
@ -90,15 +90,15 @@ def get_filter_values(request):
|
|||
|
||||
# Add all the location filters
|
||||
filter_rows += get_location_filters(request)
|
||||
filter_rows.append([''])
|
||||
filter_rows.append([' ', ' '])
|
||||
|
||||
# Add the soil filters
|
||||
filter_rows += get_soil_filters(request)
|
||||
filter_rows.append([''])
|
||||
filter_rows.append([' ', ' '])
|
||||
|
||||
# Add the project site filters
|
||||
filter_rows += get_site_filters(request)
|
||||
filter_rows.append([''])
|
||||
filter_rows.append([' ', ' '])
|
||||
|
||||
return filter_rows
|
||||
|
||||
|
|
Loading…
Reference in a new issue