diff --git a/bims/api_views/location_site.py b/bims/api_views/location_site.py index 366247c30..f9132f840 100644 --- a/bims/api_views/location_site.py +++ b/bims/api_views/location_site.py @@ -538,7 +538,7 @@ def get_site_details(self, site_id): overview['{} Site Code'.format( preferences.SiteSetting.default_site_name )] = location_site.site_code - overview['Original Site Code'] = location_site.legacy_site_code + overview['User Site Code'] = location_site.legacy_site_code overview['Site coordinates'] = ( 'Longitude: {long}, Latitude: {lat}'.format( long=self.parse_string(location_site.longitude), diff --git a/bims/api_views/location_site_public.py b/bims/api_views/location_site_public.py index 23fda798f..808a4ad26 100644 --- a/bims/api_views/location_site_public.py +++ b/bims/api_views/location_site_public.py @@ -237,7 +237,7 @@ def get_site_details(self, site_id): overview['{} Site Code'.format( preferences.SiteSetting.default_site_name )] = location_site.site_code - overview['Original Site Code'] = location_site.legacy_site_code + overview['User Site Code'] = location_site.legacy_site_code overview['Site coordinates'] = ( 'Longitude: {long}, Latitude: {lat}'.format( long=self.parse_string(location_site.longitude), diff --git a/bims/scripts/collection_csv_keys.py b/bims/scripts/collection_csv_keys.py index 970bba75c..256d93c6d 100644 --- a/bims/scripts/collection_csv_keys.py +++ b/bims/scripts/collection_csv_keys.py @@ -6,6 +6,7 @@ WETLAND_NAME = 'Original Wetland Name' LOCATION_SITE = 'Original River Name' ORIGINAL_SITE_CODE = 'Original Site Code' +USER_SITE_CODE = 'User Site Code' ORIGINAL_RIVER_NAME = 'Original River Name' FBIS_SITE_CODE = 'FBIS Site Code' SITE_DESCRIPTION = 'Site description' diff --git a/bims/scripts/occurrences_upload.py b/bims/scripts/occurrences_upload.py index fcbb83604..31259acff 100644 --- a/bims/scripts/occurrences_upload.py +++ b/bims/scripts/occurrences_upload.py @@ -259,7 +259,10 @@ def location_site(self, record): longitude, latitude) # Create or get location site - legacy_site_code = DataCSVUpload.row_value(record, ORIGINAL_SITE_CODE) + legacy_site_code = DataCSVUpload.row_value(record, USER_SITE_CODE) + if not legacy_site_code: + legacy_site_code = DataCSVUpload.row_value( + record, ORIGINAL_SITE_CODE) location_site_name = '' if DataCSVUpload.row_value(record, LOCATION_SITE): location_site_name = DataCSVUpload.row_value(record, LOCATION_SITE) diff --git a/bims/serializers/bio_collection_serializer.py b/bims/serializers/bio_collection_serializer.py index 25ad70471..912410031 100644 --- a/bims/serializers/bio_collection_serializer.py +++ b/bims/serializers/bio_collection_serializer.py @@ -97,7 +97,7 @@ class BioCollectionOneRowSerializer( uuid = serializers.SerializerMethodField() original_river_name = serializers.SerializerMethodField() site_code = serializers.SerializerMethodField() - original_site_code = serializers.SerializerMethodField() + user_site_code = serializers.SerializerMethodField() site_description = serializers.SerializerMethodField() refined_geomorphological_zone = serializers.SerializerMethodField() river_name = serializers.SerializerMethodField() @@ -277,7 +277,7 @@ def get_conservation_status_national(self, obj): def get_site_code(self, obj): return obj.site.site_code - def get_original_site_code(self, obj): + def get_user_site_code(self, obj): return obj.site.legacy_site_code def get_river_name(self, obj): @@ -603,7 +603,7 @@ class Meta: 'uuid', 'original_river_name', 'river_name', - 'original_site_code', + 'user_site_code', 'site_code', 'site_description', 'refined_geomorphological_zone', diff --git a/bims/static/data/physico_chemical_template.csv b/bims/static/data/physico_chemical_template.csv index d5170e051..833100630 100644 --- a/bims/static/data/physico_chemical_template.csv +++ b/bims/static/data/physico_chemical_template.csv @@ -1 +1 @@ -UUID,Original Wetland Name,Original Site Code,Site Code,Site description,Latitude,Longitude,Sampling Date,Collector/Owner,Collector/Owner Institute,Author(s),Year,Source,Title,Reference category,URL,DOI,Document Upload Link,Notes,AL,BOD,CA,CACO3,CHLA-B,CHLA-W,CL,CO3,COD,COL,COND,CR,CU,DIN,DO,DON,DOPER,ECOLI,FCB,FE,FE,HCO3,KJN,KJN,MG,NA,NH3-N,NH4-N,NO2+NO3,NO2-N,NO3-N,PB,pH,POM,SI,SO4,SRP,TAL,TDS,TEMP,TIC,TOC,TORGS,TOT-N,TOT-P,TSS,TURB,ZN +UUID,Original Wetland Name,User Site Code,Site Code,Site description,Latitude,Longitude,Sampling Date,Collector/Owner,Collector/Owner Institute,Author(s),Year,Source,Title,Reference category,URL,DOI,Document Upload Link,Notes,AL,BOD,CA,CACO3,CHLA-B,CHLA-W,CL,CO3,COD,COL,COND,CR,CU,DIN,DO,DON,DOPER,ECOLI,FCB,FE,FE,HCO3,KJN,KJN,MG,NA,NH3-N,NH4-N,NO2+NO3,NO2-N,NO3-N,PB,pH,POM,SI,SO4,SRP,TAL,TDS,TEMP,TIC,TOC,TORGS,TOT-N,TOT-P,TSS,TURB,ZN diff --git a/bims/templates/includes/overview_table.html b/bims/templates/includes/overview_table.html index a4cd4131d..cf1931366 100644 --- a/bims/templates/includes/overview_table.html +++ b/bims/templates/includes/overview_table.html @@ -16,8 +16,8 @@ {% if site_code %}{{ site_code }}{% elif location_site %}{{ location_site.site_code }}{% endif %} - Original Site Code - {% if original_site_code %}{{ original_site_code }}{% elif location_site %}{{ location_site.legacy_site_code }}{% endif %} + User Site Code + {% if user_site_code %}{{ user_site_code }}{% elif location_site %}{{ location_site.legacy_site_code }}{% endif %} Site coordinates diff --git a/bims/templates/location_site_detail.html b/bims/templates/location_site_detail.html index 0e92f0b1e..3a561d079 100644 --- a/bims/templates/location_site_detail.html +++ b/bims/templates/location_site_detail.html @@ -112,7 +112,7 @@

-
+ class="col-sm-2 col-form-label col-form-label">User Site Code
-
+ class="col-sm-2 col-form-label col-form-label">User Site Code
SASS Dashboard

{{ site_code }} - Original Site Code - {{ original_site_code }} + User Site Code + {{ user_site_code }} Site coordinates diff --git a/sass/views/sass_dashboard.py b/sass/views/sass_dashboard.py index e8d137521..e7ab572dc 100644 --- a/sass/views/sass_dashboard.py +++ b/sass/views/sass_dashboard.py @@ -349,7 +349,7 @@ def get_context_data(self, **kwargs): context['site_id'] = self.location_site.id context['site_image'] = SiteImage.objects.filter( site=self.location_site) - context['original_site_code'] = self.location_site.legacy_site_code + context['user_site_code'] = self.location_site.legacy_site_code context['original_river_name'] = self.location_site.legacy_river_name site_description = self.location_site.site_description if not site_description: diff --git a/scripts/management/commands/get_sites_outside_sa.py b/scripts/management/commands/get_sites_outside_sa.py index 642d48ad7..a30b51acf 100644 --- a/scripts/management/commands/get_sites_outside_sa.py +++ b/scripts/management/commands/get_sites_outside_sa.py @@ -45,7 +45,7 @@ def handle(self, *args, **options): csv_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) writer.writerow([ - 'Site Code', 'Original Site Code', 'Lat', 'Lon', 'Link']) + 'Site Code', 'User Site Code', 'Lat', 'Lon', 'Link']) for site in sites: print(site) csv_data = [] diff --git a/scripts/management/commands/import_collection_data.py b/scripts/management/commands/import_collection_data.py index ddbf52e54..0802550b3 100644 --- a/scripts/management/commands/import_collection_data.py +++ b/scripts/management/commands/import_collection_data.py @@ -58,6 +58,7 @@ LONGITUDE = 'Longitude' LOCATION_SITE = 'Original River Name' ORIGINAL_SITE_CODE = 'Original Site Code' +USER_SITE_CODE = 'User Site Code' ORIGINAL_RIVER_NAME = 'Original River Name' FBIS_SITE_CODE = 'FBIS Site Code' SITE_DESCRIPTION = 'Site description' @@ -578,7 +579,9 @@ def location_site(self, record): float(self.row_value(record, LONGITUDE)), float(self.row_value(record, LATITUDE))) # Create or get location site - legacy_site_code = self.row_value(record, ORIGINAL_SITE_CODE) + legacy_site_code = self.row_value(record, USER_SITE_CODE) + if not legacy_site_code: + legacy_site_code = self.row_value(record, ORIGINAL_SITE_CODE) try: location_site, status = ( LocationSite.objects.get_or_create( diff --git a/scripts/management/commands/update_sites_from_csv.py b/scripts/management/commands/update_sites_from_csv.py index 034f52971..0ed4fd5ce 100644 --- a/scripts/management/commands/update_sites_from_csv.py +++ b/scripts/management/commands/update_sites_from_csv.py @@ -12,7 +12,7 @@ LONGITUDE = 'Longitude' CORRECTED_LATITUDE = 'Corrected Latitude' CORRECTED_LONGITUDE = 'Corrected Longitude' -ORIGINAL_SITE_CODE = 'Original Site Code' +USER_SITE_CODE = 'User Site Code' REFINED_GEO_ZONE = 'Refined Geomorphological Zone' ORIGINAL_RIVER_NAME = 'Original River Name' FBIS_SITE_CODE = 'FBIS Site Code' @@ -51,11 +51,11 @@ def handle(self, *args, **options): csv_reader = csv.DictReader(csv_file) for row in csv_reader: # Search LocationSite with the same original latitude and longitude - if ORIGINAL_SITE_CODE in row: + if USER_SITE_CODE in row: location_sites = LocationSite.objects.filter( - legacy_site_code=row[ORIGINAL_SITE_CODE] + legacy_site_code=row[USER_SITE_CODE] ) - site_code = ORIGINAL_SITE_CODE + site_code = USER_SITE_CODE elif FBIS_SITE_CODE in row: location_sites = LocationSite.objects.filter( site_code=row[FBIS_SITE_CODE]