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/2212pid dashes #2273

Merged
merged 4 commits into from
Jul 24, 2024
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
2 changes: 1 addition & 1 deletion app/backend/wells/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def filter_combined_legal(self, queryset, name, value):
# Check if we have a positive integer before querying the
# legal_pid field.
try:
int_value = int(value.replace("-",""))
int_value = int(value.replace("-", ""))
except (TypeError, ValueError):
pass
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
<p class="font-weight-bold">3) Parcel Identifier (PID)</p>
<form-input
id="legalPID"
type="number"
type="text"
hint="*Input a 9 digit number (including leading zeroes, if necessary)"
v-model="legalPIDInput"
:errors="errors['legal_pid']"
Expand Down
41 changes: 23 additions & 18 deletions app/frontend/src/submissions/views/SubmissionsHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ export default {
data.well = data.well.well_tag_number
}

if (data.legal_pid) {
data.legal_pid = data.legal_pid.replace(/-/g, '');
}

if (!this.isStaffEdit) {
let skipKeys = []
// we need both ground elevation and its method to be sent for validation on submission
Expand Down Expand Up @@ -322,7 +326,7 @@ export default {
if (window.location.href.indexOf('localhost:8080') > -1 ||
window.location.href.indexOf('gwells-dev-pr') > -1 ||
window.location.href.indexOf('gwells-staging') > -1
) {
) {
testEnv = true
}

Expand Down Expand Up @@ -587,7 +591,7 @@ export default {
},
groundwaterProtectionRegulationValidation(errors) {
const {
owner_full_name,
owner_full_name,
owner_mailing_address,
owner_city,
owner_province_state,
Expand All @@ -614,15 +618,15 @@ export default {
}
},
validateWellIdentificationPlateFields(errors) {
const {
const {
well_class,
identification_plate_number,
well_identification_plate_attached,
} = this.form

const validateWellClasses = [WELL_CLASS.WATER_SUPPLY, WELL_CLASS.INJECTION, WELL_CLASS.RECHARGE]
const isWellIdentificationPlateToBeVerified = validateWellClasses.includes(well_class)

if (isWellIdentificationPlateToBeVerified == false) { return; }

if (!identification_plate_number) {
Expand All @@ -633,11 +637,11 @@ export default {
}
},
validateWellFields(errors) {
const {
work_start_date,
work_end_date,
drilling_methods,
total_depth_drilled,
const {
work_start_date,
work_end_date,
drilling_methods,
total_depth_drilled,
finished_well_depth
} = this.form;

Expand All @@ -650,19 +654,19 @@ export default {
if (drilling_methods.length === 0) {
errors.drilling_methods = ['Drilling Methods Required.'];
}
if (!total_depth_drilled) {
errors.total_depth_drilled = ['Total Depth Drilled Required.'];
if (!total_depth_drilled) {
errors.total_depth_drilled = ['Total Depth Drilled Required.'];
}
if (!finished_well_depth) {
errors.finished_well_depth = ['Finished Well Depth Required.'];
if (!finished_well_depth) {
errors.finished_well_depth = ['Finished Well Depth Required.'];
}
},
newlyConstructedWellValidation(errors) {
const {
const {
work_start_date,
work_end_date,
} = this.form

const mandatoryLicensingDate = NEW_WELL_CONSTRUCTION_VALIDATION_DATE;

const workStartDatePastWorkEndDate = ((work_start_date !== '' && work_end_date !== '') && work_start_date > work_end_date);
Expand Down Expand Up @@ -702,7 +706,8 @@ export default {
const locationAddressValidate = !!street_address && !!city;
// for legalDescription a user is only required to fill in a minimum one field
const legalDescriptionValidate = legalDescriptionFields.some((item) => !!item);
const pidAddressValidate = legal_pid > 0;
const pidNum = legal_pid.replace(/-/g, '');
const pidAddressValidate = Number(pidNum) > 0;

if(locationAddressValidate || legalDescriptionValidate || pidAddressValidate) { return; }
errors.well_location_section = ['Well location not filled out'];
Expand All @@ -729,14 +734,14 @@ export default {
if (!this.form.latitude){
errors.latitude = ['Valid Latitude Required'];
}
if (!this.form.longitude) {
if (!this.form.longitude) {
errors.longitude = ['Valid Longitude Required']
}
} else if (wellCoordsNotWithinBC) {
errors.position = ['Coordinates not within BC']
}
}

// Always validate well_class and intended_water_use except for ALT or DEC submissions with a
// well_tag_number specified
if (validateWellClassAndIntendedWaterUse) {
Expand Down
145 changes: 139 additions & 6 deletions tests/api-tests/submissions_api_tests.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"info": {
"_postman_id": "e90dc2af-da89-4df4-a49c-71d29b09c874",
"_postman_id": "8f8fdc37-50fd-4fe6-a3b4-e51a83c1c108",
"name": "GWELLS Submissions API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "33152761"
"_exporter_id": "37028467"
},
"item": [
{
Expand Down Expand Up @@ -391,7 +391,6 @@
},
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
Expand Down Expand Up @@ -2017,6 +2016,74 @@
{
"name": "Decommission",
"item": [
{
"name": "Log in Copy",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var jsonData = pm.response.json()",
"pm.environment.set(\"token\", jsonData.access_token);",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.expect(pm.response.code, \"Login was not successful\").to.equal(200);",
"})",
"",
"pm.test(\"A token was returned\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.access_token, \"a token was not returned\").to.be.ok;",
" pm.expect(jsonData.access_token.length).to.be.above(36);",
"});",
""
]
}
}
],
"request": {
"auth": {
"type": "basic",
"basic": [
{
"key": "password",
"value": "{{client_secret}}",
"type": "string"
},
{
"key": "username",
"value": "{{client_id}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "grant_type",
"value": "client_credentials",
"type": "text"
}
]
},
"url": {
"raw": "{{auth_server}}",
"host": [
"{{auth_server}}"
]
},
"description": "Get token (log in)"
},
"response": []
},
{
"name": "Decommission well",
"event": [
Expand Down Expand Up @@ -2597,6 +2664,74 @@
}
]
},
{
"name": "Log in Copy",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var jsonData = pm.response.json()",
"pm.environment.set(\"token\", jsonData.access_token);",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.expect(pm.response.code, \"Login was not successful\").to.equal(200);",
"})",
"",
"pm.test(\"A token was returned\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.access_token, \"a token was not returned\").to.be.ok;",
" pm.expect(jsonData.access_token.length).to.be.above(36);",
"});",
""
]
}
}
],
"request": {
"auth": {
"type": "basic",
"basic": [
{
"key": "password",
"value": "{{client_secret}}",
"type": "string"
},
{
"key": "username",
"value": "{{client_id}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "grant_type",
"value": "client_credentials",
"type": "text"
}
]
},
"url": {
"raw": "{{auth_server}}",
"host": [
"{{auth_server}}"
]
},
"description": "Get token (log in)"
},
"response": []
},
{
"name": "staff_edit Get",
"event": [
Expand Down Expand Up @@ -2945,7 +3080,6 @@
},
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
Expand Down Expand Up @@ -3080,7 +3214,6 @@
},
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
Expand Down Expand Up @@ -3833,4 +3966,4 @@
]
}
]
}
}
Loading
Loading