Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GWELLS-2045] BUGFIX/UPDATE** Update dropdown list values, show full name instead of codes #2071

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.core.management.base import BaseCommand
from wells.models import AnalysisMethodCode
from collections import defaultdict
import json

class Command(BaseCommand):
help = "Update values in the analysis_method_code table"
def update_analysis_method_codes(self):
analysis_method_codes = open("wells/migrations/analysis_method_codes.json")
analysis_codes = json.load(analysis_method_codes)
for entry in analysis_codes:
AnalysisMethodCode.objects.update_or_create(pk=entry["pk"], defaults=entry["fields"])

def handle(self, *args, **options):
self.update_analysis_method_codes()
print("update_analysis_method_codes.py completed successfully")
19 changes: 19 additions & 0 deletions app/backend/wells/management/commands/update_codes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.core.management import call_command
from django.core.management.base import BaseCommand
import os, fnmatch

class Command(BaseCommand):
file_pattern = 'update_*_codes.py'
folder_path = './wells/management/commands'
help = f'Run all commands using the {file_pattern} format'


def handle(self, *args, **options):
matching_files = []
for file_name in os.listdir(self.folder_path):
if fnmatch.fnmatch(file_name, self.file_pattern):
matching_files.append(file_name)
print(len(matching_files), "files found")
for file_path in matching_files:
call_command(file_path.replace(".py",""))
print("update_codes has completed successfully")
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.core.management.base import BaseCommand
from wells.models import PumpingTestDescriptionCode
from collections import defaultdict
import json

class Command(BaseCommand):
help = "Update values in the pumping_test_description_code table"

def update_pumping_test_description_codes(self):
pumping_test_description_codes = open("wells/migrations/pumping_test_description_codes.json")
pumping_codes = json.load(pumping_test_description_codes)
for entry in pumping_codes:
PumpingTestDescriptionCode.objects.update_or_create(pk=entry["pk"], defaults=entry["fields"])

def handle(self, *args, **options):
self.update_pumping_test_description_codes()
print("update_pumping_test_description_codes.py completed successfully")
4 changes: 2 additions & 2 deletions app/backend/wells/migrations/analysis_method_codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@
"create_date": "2023-03-31T17:42:52.421Z",
"update_user": "DATALOAD_USER",
"update_date": "2023-03-31T17:42:52.421Z",
"description": "Other - Please use comments field",
"description": "Other",
"display_order": 6,
"effective_date": "2013-11-07T05:28:00.402Z",
"expiry_date": "9999-12-31T23:59:59Z"
}
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"create_date": "2023-03-31T17:42:52.421Z",
"update_user": "DATALOAD_USER",
"update_date": "2023-03-31T17:42:52.421Z",
"description": "PT - Pumping Well",
"description": "Pumping test - pumping well",
"display_order": 1,
"effective_date": "2013-11-07T05:28:00.402Z",
"expiry_date": "9999-12-31T23:59:59Z"
Expand All @@ -34,7 +34,7 @@
"create_date": "2023-03-31T17:42:52.421Z",
"update_user": "DATALOAD_USER",
"update_date": "2023-03-31T17:42:52.421Z",
"description": "PT - Observation Well",
"description": "Pumping test - observation well",
"display_order": 2,
"effective_date": "2013-11-07T05:28:00.402Z",
"expiry_date": "9999-12-31T23:59:59Z"
Expand Down Expand Up @@ -76,10 +76,10 @@
"create_date": "2023-03-31T17:42:52.421Z",
"update_user": "DATALOAD_USER",
"update_date": "2023-03-31T17:42:52.421Z",
"description": "Other - Please use comments field",
"description": "Other",
"display_order": 5,
"effective_date": "2013-11-07T05:28:00.402Z",
"expiry_date": "9999-12-31T23:59:59Z"
}
}
]
]
10 changes: 5 additions & 5 deletions app/frontend/src/wells/views/WellDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,9 @@ Licensed under the Apache License, Version 2.0 (the "License");
<template v-slot:cell(pumping_test_description)="data">{{codeToDescription('pumping_test_description_codes', data.item.pumping_test_description)}}</template>
<template v-slot:cell(boundary_effect)="data">{{codeToDescription('boundary_effect_codes', data.item.boundary_effect)}}</template>
<template v-slot:cell(analysis_method)="data">{{codeToDescription('analysis_method_codes', data.item.analysis_method)}}</template>
<template v-slot:cell(storativity)="data">{{parseFloat(data.item.storativity).toString()}}</template>
<template v-slot:cell(transmissivity)="data">{{parseFloat(data.item.transmissivity).toString()}}</template>
<template v-slot:cell(hydraulic_conductivity)="data">{{parseFloat(data.item.hydraulic_conductivity).toString()}}</template>
<template v-slot:cell(storativity)="data">{{data.item.storativity && parseFloat(data.item.storativity).toString()}}</template>
<template v-slot:cell(transmissivity)="data">{{data.item.transmissivity && parseFloat(data.item.transmissivity).toString()}}</template>
<template v-slot:cell(hydraulic_conductivity)="data">{{data.item.hydraulic_conductivity && parseFloat(data.item.hydraulic_conductivity).toString()}}</template>
</b-table>
</div>
</fieldset>
Expand Down Expand Up @@ -541,7 +541,7 @@ import Documents from '@/wells/components/Documents.vue'
import convertCoordinatesMixin from '@/common/convertCoordinatesMixin.js'
import ApiService from '@/common/services/ApiService.js'
import codeToDescription from '@/common/codeToDescription.js'

import { FETCH_CODES } from '@/submissions/store/actions.types.js'
import { RESET_WELL_DATA } from '@/wells/store/actions.types.js'
import { SET_WELL_RECORD, SET_WELL_LICENCE } from '@/wells/store/mutations.types.js'

Expand Down Expand Up @@ -689,7 +689,7 @@ export default {
},
created () {
this.fetchSurveys()

this.$store.dispatch(FETCH_CODES)
if (this.id === null) {
this.error = `Unable to load well '${this.id}'`
}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ services:
### Volumes ###
#############################################################################################
pgadmin:
container_name: pgadmin
container_name: gwells-pgadmin
image: dpage/pgadmin4
ports:
- 5050:80
Expand Down