Skip to content

Commit

Permalink
Change Original Site Code to User Site Code
Browse files Browse the repository at this point in the history
  • Loading branch information
dimasciput committed Jul 26, 2023
1 parent 3e62b0c commit 1c7e85a
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion bims/api_views/location_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
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 @@ -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),
Expand Down
1 change: 1 addition & 0 deletions bims/scripts/collection_csv_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 4 additions & 1 deletion bims/scripts/occurrences_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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 @@ -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()
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion bims/static/data/physico_chemical_template.csv
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions bims/templates/includes/overview_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<td>{% if site_code %}{{ site_code }}{% elif location_site %}{{ location_site.site_code }}{% endif %}</td>
</tr>
<tr>
<th>Original Site Code</th>
<td>{% if original_site_code %}{{ original_site_code }}{% elif location_site %}{{ location_site.legacy_site_code }}{% endif %}</td>
<th>User Site Code</th>
<td>{% if user_site_code %}{{ user_site_code }}{% elif location_site %}{{ location_site.legacy_site_code }}{% endif %}</td>
</tr>
<tr>
<th>Site coordinates</th>
Expand Down
4 changes: 2 additions & 2 deletions bims/templates/location_site_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ <h2>
</div>
</div>
<div class="form-group row">
<label for="original_site_code"
<label for="original_river_name"
class="col-sm-2 col-form-label col-form-label">Original River Name</label>
<div class="col-sm-10">
<input type="text" name="original_river_name" id="original_river_name"
Expand All @@ -133,7 +133,7 @@ <h2>
</div>
<div class="form-group row">
<label for="legacy_site_code"
class="col-sm-2 col-form-label col-form-label">Original Site Code</label>
class="col-sm-2 col-form-label col-form-label">User Site Code</label>
<div class="col-sm-10">
<input type="text" name="legacy_site_code" id="legacy_site_code"
class="form-control form-control-sm"
Expand Down
4 changes: 2 additions & 2 deletions bims/templates/location_site_form_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ <h2>
</div>
</div>
<div class="form-group row">
<label for="original_site_code"
<label for="original_river_name"
class="col-sm-2 col-form-label col-form-label">Original River Name</label>
<div class="col-sm-10">
<input type="text" name="original_river_name" id="original_river_name"
Expand Down Expand Up @@ -193,7 +193,7 @@ <h2>
</div>
<div class="form-group row">
<label for="legacy_site_code"
class="col-sm-2 col-form-label col-form-label">Original Site Code</label>
class="col-sm-2 col-form-label col-form-label">User Site Code</label>
<div class="col-sm-10">
<input type="text" name="legacy_site_code" id="legacy_site_code"
class="form-control form-control-sm"
Expand Down
2 changes: 1 addition & 1 deletion bims/views/physico_chemical.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def get_context_data(self, **kwargs):
]
ctx['site_code'] = self.location_site.site_code
ctx['site_id'] = self.location_site.id
ctx['original_site_code'] = self.location_site.legacy_site_code
ctx['user_site_code'] = self.location_site.legacy_site_code
ctx['original_river_name'] = self.location_site.legacy_river_name
ctx['site_image'] = SiteImage.objects.filter(
site=self.location_site
Expand Down
2 changes: 1 addition & 1 deletion bims/views/water_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def get_context_data(self, **kwargs):
]
context['site_code'] = self.location_site.site_code
context['site_id'] = self.location_site.id
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_images = SiteImage.objects.filter(
site=self.location_site
Expand Down
12 changes: 6 additions & 6 deletions sass/serializers/sass_data_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SassDataSerializer(serializers.ModelSerializer, FilterHistorySerializer):
filter_history = serializers.SerializerMethodField()
original_river_name = serializers.SerializerMethodField()
FBIS_site_code = serializers.SerializerMethodField()
original_site_code = serializers.SerializerMethodField()
user_site_code = serializers.SerializerMethodField()
site_description = serializers.SerializerMethodField()
river_name = serializers.SerializerMethodField()
geomorphological_zone = serializers.SerializerMethodField()
Expand All @@ -84,7 +84,7 @@ class Meta:
'filter_history',
'FBIS_site_code',
'original_river_name',
'original_site_code',
'user_site_code',
'site_description',
'river_name',
'geomorphological_zone',
Expand Down Expand Up @@ -243,7 +243,7 @@ def get_original_river_name(self, obj):
return obj.site_visit.location_site.legacy_river_name
return '-'

def get_original_site_code(self, obj):
def get_user_site_code(self, obj):
if obj.site_visit.location_site.legacy_site_code:
return obj.site_visit.location_site.legacy_site_code
return '-'
Expand All @@ -254,7 +254,7 @@ class SassSummaryDataSerializer(
filter_history = serializers.SerializerMethodField()
original_river_name = serializers.SerializerMethodField()
FBIS_site_code = serializers.SerializerMethodField()
original_site_code = serializers.SerializerMethodField()
user_site_code = serializers.SerializerMethodField()
sass_score = serializers.SerializerMethodField()
number_of_taxa = serializers.SerializerMethodField()
ASPT = serializers.SerializerMethodField()
Expand Down Expand Up @@ -469,7 +469,7 @@ def get_original_river_name(self, obj):
return site.legacy_river_name
return '-'

def get_original_site_code(self, obj):
def get_user_site_code(self, obj):
site = LocationSite.objects.get(id=obj['site_id'])
if site.legacy_site_code:
return site.legacy_site_code
Expand All @@ -495,7 +495,7 @@ class Meta:
'filter_history',
'FBIS_site_code',
'original_river_name',
'original_site_code',
'user_site_code',
'site_description',
'river_name',
'geomorphological_zone',
Expand Down
4 changes: 2 additions & 2 deletions sass/templates/sass_dashboard_single_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ <h2 class="dashboard-title">SASS Dashboard</h2>
<td>{{ site_code }}</td>
</tr>
<tr>
<td scope="row">Original Site Code</td>
<td>{{ original_site_code }}</td>
<td scope="row">User Site Code</td>
<td>{{ user_site_code }}</td>
</tr>
<tr>
<td scope="row">Site coordinates</td>
Expand Down
2 changes: 1 addition & 1 deletion sass/views/sass_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/management/commands/get_sites_outside_sa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
5 changes: 4 additions & 1 deletion scripts/management/commands/import_collection_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions scripts/management/commands/update_sites_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 1c7e85a

Please sign in to comment.