Skip to content

Commit

Permalink
Update ecosystem characteristic panel (#3543)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimasciput authored Oct 20, 2023
1 parent 1d2e5ba commit c96db10
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 18 deletions.
33 changes: 30 additions & 3 deletions bims/api_views/location_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
)
from bims.tasks.email_csv import send_csv_via_email
from bims.tasks.collection_record import download_gbif_ids
from bims.enums.ecosystem_type import ECOSYSTEM_WETLAND


class LocationSiteList(APIView):
Expand Down Expand Up @@ -559,9 +560,14 @@ def get_site_details(self, site_id):

if preferences.SiteSetting.site_code_generator == 'fbis':
river_and_geo = OrderedDict()
river_and_geo['River/Wetland/Open Waterbody/Unspecified'] = (
location_site.ecosystem_type
)
river_and_geo['River'] = site_river
river_and_geo[
'User River Name'] = location_site.legacy_river_name
'User River Name'] = (
location_site.legacy_river_name if location_site.legacy_river_name else '-'
)
river_and_geo['Geomorphological zone'] = (
location_context.value_from_key(
'geo_class_recoded')
Expand All @@ -571,10 +577,31 @@ def get_site_details(self, site_id):
refined_geomorphological = (
location_site.refined_geomorphological
)
river_and_geo['Original Geomorphological zone'] = (
river_and_geo['User Geomorphological zone'] = (
refined_geomorphological
)
result['River and Geomorphological Zone'] = river_and_geo
river_and_geo['Wetland Name (NWM6)'] = (
location_site.wetland_name if location_site.wetland_name else '-'
)
river_and_geo['User Wetland Name'] = (
location_site.user_wetland_name if location_site.user_wetland_name else '-'
)
river_and_geo['Hydrogeomorphic Type (NWM6)'] = (
location_site.hydrogeomorphic_type if location_site.hydrogeomorphic_type else '-'
)
river_and_geo['User Hydrogeomorphic Type'] = (
location_site.user_hydrogeomorphic_type if location_site.user_hydrogeomorphic_type else '-'
)

wetland_area = ''
if location_site.ecosystem_type == ECOSYSTEM_WETLAND and location_site.additional_data:
wetland_area = location_site.additional_data.get('area_ha', '')

river_and_geo['Wetland area (hectares)'] = (
wetland_area if wetland_area else '-'
)

result['Ecosystem Characteristics'] = river_and_geo

# Location context group data
location_context_filters = (
Expand Down
2 changes: 1 addition & 1 deletion bims/api_views/location_site_public.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def get_site_details(self, site_id):
refined_geomorphological = (
location_site.refined_geomorphological
)
river_and_geo['Original Geomorphological zone'] = (
river_and_geo['User Geomorphological zone'] = (
refined_geomorphological
)
result['River and Geomorphological Zone'] = river_and_geo
Expand Down
1 change: 1 addition & 0 deletions bims/enums/ecosystem_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ECOSYSTEM_RIVER = 'River'
ECOSYSTEM_WETLAND = 'Wetland'
ECOSYSTEM_OPEN_WATERBODY = 'Open waterbody'
ECOSYSTEM_UNSPECIFIED = 'Unspecified'

ECOSYSTEM_TYPE_CHOICES = (
(ECOSYSTEM_RIVER, ECOSYSTEM_RIVER),
Expand Down
2 changes: 1 addition & 1 deletion bims/models/location_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class LocationSite(DocumentLinksMixin, AbstractValidation):
blank=True,
null=True,
max_length=200,
verbose_name='Original geomorphological',
verbose_name='User geomorphological',
choices=[(g.value, g.value) for g in GeomorphologicalZoneCategory],
help_text='Would be used in preference to the one discovered '
'in geocontext',
Expand Down
2 changes: 1 addition & 1 deletion bims/scripts/collection_csv_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
FBIS_SITE_CODE = 'FBIS Site Code'
SITE_DESCRIPTION = 'Site description'
REFINED_GEO_ZONE = 'Refined Geomorphological Zone'
ORIGINAL_GEO_ZONE = 'Original Geomorphological Zone'
ORIGINAL_GEO_ZONE = 'User Geomorphological Zone'
USER_HYDROGEOMORPHIC_TYPE = 'User Hydrogeomorphic Type'
ENDEMISM = 'Endemism'
CATEGORY = 'Category'
Expand Down
6 changes: 3 additions & 3 deletions bims/serializers/bio_collection_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class BioCollectionOneRowSerializer(
site_code = serializers.SerializerMethodField()
user_site_code = serializers.SerializerMethodField()
site_description = serializers.SerializerMethodField()
original_geomorphological_zone = serializers.SerializerMethodField()
user_geomorphological_zone = serializers.SerializerMethodField()
river_name = serializers.SerializerMethodField()
latitude = serializers.SerializerMethodField()
longitude = serializers.SerializerMethodField()
Expand Down Expand Up @@ -264,7 +264,7 @@ def get_user_river_name(self, obj):
return obj.site.legacy_river_name
return '-'

def get_original_geomorphological_zone(self, obj):
def get_user_geomorphological_zone(self, obj):
if obj.site.refined_geomorphological:
return obj.site.refined_geomorphological
return '-'
Expand Down Expand Up @@ -633,7 +633,7 @@ class Meta:
'site_code',
'ecosystem_type',
'site_description',
'original_geomorphological_zone',
'user_geomorphological_zone',
'latitude',
'longitude',
'sampling_date',
Expand Down
2 changes: 1 addition & 1 deletion bims/templates/includes/overview_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
let $table = $('.summary-table tbody');
let tableData = {
'Geomorphological zone': '-',
'Original Geomorphological zone': refinedGeomorphologicalZone,
'User Geomorphological zone': refinedGeomorphologicalZone,
'Catchments': 'title',
'Primary Catchment': '-',
'Secondary Catchment': '-',
Expand Down
13 changes: 6 additions & 7 deletions bims/views/site_visit/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
from django.contrib.auth import get_user_model
from django.db.models import Subquery, OuterRef
from bims.models.survey import Survey
from bims.models.location_site import LocationSite
from bims.enums.ecosystem_type import (
ECOSYSTEM_RIVER,
ECOSYSTEM_WETLAND,
ECOSYSTEM_OPEN_WATERBODY,
ECOSYSTEM_UNSPECIFIED
)
from bims.models.biological_collection_record import BiologicalCollectionRecord
from bims.models.taxon_group import TaxonGroup, TaxonomicGroupCategory
from bims.api_views.search import CollectionSearch
Expand Down Expand Up @@ -41,12 +46,6 @@ def get_queryset(self):
# Base queryset
qs = super(SiteVisitListView, self).get_queryset()

# Get all ecosystem type
search_filters['ecosystemType'] = ','.join(list(
LocationSite.objects.all().values_list(
'ecosystem_type', flat=True).distinct()
))

if search_filters:
search = CollectionSearch(search_filters)

Expand Down
2 changes: 1 addition & 1 deletion scripts/management/commands/import_collection_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
FBIS_SITE_CODE = 'FBIS Site Code'
SITE_DESCRIPTION = 'Site description'
REFINED_GEO_ZONE = 'Refined Geomorphological Zone'
ORIGINAL_GEO_ZONE = 'Original Geomorphological Zone'
ORIGINAL_GEO_ZONE = 'User Geomorphological Zone'
ENDEMISM = 'Endemism'
CATEGORY = 'Category'
ORIGIN = 'Origin'
Expand Down

0 comments on commit c96db10

Please sign in to comment.