From 866aedd7adfef275b94b06b4556e7b2db881ac44 Mon Sep 17 00:00:00 2001
From: luna <5862lunamoon@gmail.com>
Date: Wed, 10 Jul 2024 15:30:32 -0700
Subject: [PATCH 1/4] changes to submission validation for PID
---
app/backend/wells/filters.py | 2 +-
app/frontend/src/submissions/views/SubmissionsHome.vue | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/backend/wells/filters.py b/app/backend/wells/filters.py
index 682aadce9..abb5907c5 100644
--- a/app/backend/wells/filters.py
+++ b/app/backend/wells/filters.py
@@ -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:
diff --git a/app/frontend/src/submissions/views/SubmissionsHome.vue b/app/frontend/src/submissions/views/SubmissionsHome.vue
index 537326385..84d1545f6 100644
--- a/app/frontend/src/submissions/views/SubmissionsHome.vue
+++ b/app/frontend/src/submissions/views/SubmissionsHome.vue
@@ -702,7 +702,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'];
From d2336b455dcaa51180ef0efed4858e9c9b07a50a Mon Sep 17 00:00:00 2001
From: luna <5862lunamoon@gmail.com>
Date: Wed, 10 Jul 2024 16:24:54 -0700
Subject: [PATCH 2/4] changed so legal_pid saves without dashes even when
entered with dashes
---
app/backend/wells/models.py | 3 ++
.../components/SubmissionForm/Location.vue | 2 +-
.../src/submissions/views/SubmissionsHome.vue | 38 ++++++++++---------
3 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/app/backend/wells/models.py b/app/backend/wells/models.py
index 3c9c2b0b1..aea89c297 100644
--- a/app/backend/wells/models.py
+++ b/app/backend/wells/models.py
@@ -1912,6 +1912,9 @@ def save(self, *args, **kwargs):
if not self.create_date:
self.create_date = timezone.now()
+ if self.legal_pid:
+ self.legal_pid = self.legal_pid.replace('-', '')
+
return super().save(*args, **kwargs)
diff --git a/app/frontend/src/submissions/components/SubmissionForm/Location.vue b/app/frontend/src/submissions/components/SubmissionForm/Location.vue
index 35036e012..8a5ea6e55 100644
--- a/app/frontend/src/submissions/components/SubmissionForm/Location.vue
+++ b/app/frontend/src/submissions/components/SubmissionForm/Location.vue
@@ -191,7 +191,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
3) Parcel Identifier (PID)
-1 ||
window.location.href.indexOf('gwells-dev-pr') > -1 ||
window.location.href.indexOf('gwells-staging') > -1
- ) {
+ ) {
testEnv = true
}
@@ -587,7 +591,7 @@ export default {
},
groundwaterProtectionRegulationValidation(errors) {
const {
- owner_full_name,
+ owner_full_name,
owner_mailing_address,
owner_city,
owner_province_state,
@@ -614,7 +618,7 @@ export default {
}
},
validateWellIdentificationPlateFields(errors) {
- const {
+ const {
well_class,
identification_plate_number,
well_identification_plate_attached,
@@ -622,7 +626,7 @@ export default {
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) {
@@ -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;
@@ -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);
@@ -730,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) {
From 82a51c93fa5d444bfdb3e1ac48ec4ddedf74105f Mon Sep 17 00:00:00 2001
From: luna <5862lunamoon@gmail.com>
Date: Wed, 17 Jul 2024 14:21:55 -0700
Subject: [PATCH 3/4] commented out duplicate logic
---
app/backend/wells/models.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/backend/wells/models.py b/app/backend/wells/models.py
index aea89c297..469202f0a 100644
--- a/app/backend/wells/models.py
+++ b/app/backend/wells/models.py
@@ -1912,8 +1912,9 @@ def save(self, *args, **kwargs):
if not self.create_date:
self.create_date = timezone.now()
- if self.legal_pid:
- self.legal_pid = self.legal_pid.replace('-', '')
+ # Logic already on the frontend in filters.py
+ # if self.legal_pid:
+ # self.legal_pid = self.legal_pid.replace('-', '')
return super().save(*args, **kwargs)
From 20605c7986c01d997c3214fc6d54cccac27de122 Mon Sep 17 00:00:00 2001
From: luna <5862lunamoon@gmail.com>
Date: Thu, 18 Jul 2024 10:02:27 -0700
Subject: [PATCH 4/4] removed commented out code and added additional logins to
testing
---
app/backend/wells/models.py | 4 -
tests/api-tests/submissions_api_tests.json | 145 ++++++++++++++++-
tests/api-tests/submissions_v2_api_tests.json | 147 +++++++++++++++++-
3 files changed, 279 insertions(+), 17 deletions(-)
diff --git a/app/backend/wells/models.py b/app/backend/wells/models.py
index 469202f0a..3c9c2b0b1 100644
--- a/app/backend/wells/models.py
+++ b/app/backend/wells/models.py
@@ -1912,10 +1912,6 @@ def save(self, *args, **kwargs):
if not self.create_date:
self.create_date = timezone.now()
- # Logic already on the frontend in filters.py
- # if self.legal_pid:
- # self.legal_pid = self.legal_pid.replace('-', '')
-
return super().save(*args, **kwargs)
diff --git a/tests/api-tests/submissions_api_tests.json b/tests/api-tests/submissions_api_tests.json
index 5b5828e12..cc75e87b3 100644
--- a/tests/api-tests/submissions_api_tests.json
+++ b/tests/api-tests/submissions_api_tests.json
@@ -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": [
{
@@ -391,7 +391,6 @@
},
{
"key": "Content-Type",
- "name": "Content-Type",
"value": "application/json",
"type": "text"
}
@@ -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": [
@@ -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": [
@@ -2945,7 +3080,6 @@
},
{
"key": "Content-Type",
- "name": "Content-Type",
"value": "application/json",
"type": "text"
}
@@ -3080,7 +3214,6 @@
},
{
"key": "Content-Type",
- "name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
@@ -3833,4 +3966,4 @@
]
}
]
-}
+}
\ No newline at end of file
diff --git a/tests/api-tests/submissions_v2_api_tests.json b/tests/api-tests/submissions_v2_api_tests.json
index e3a479103..d781de23e 100644
--- a/tests/api-tests/submissions_v2_api_tests.json
+++ b/tests/api-tests/submissions_v2_api_tests.json
@@ -1,9 +1,9 @@
{
"info": {
- "_postman_id": "5af206dc-0c56-4a30-b354-9ba715416251",
+ "_postman_id": "d906d14c-be47-49d7-a5d0-524794bc2d59",
"name": "GWELLS Submissions API v2",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
- "_exporter_id": "33152761"
+ "_exporter_id": "37028467"
},
"item": [
{
@@ -349,7 +349,6 @@
},
{
"key": "Content-Type",
- "name": "Content-Type",
"value": "application/json",
"type": "text"
}
@@ -1878,7 +1877,7 @@
"name": "Decommission",
"item": [
{
- "name": "Log in Copy",
+ "name": "Log in Copy 3",
"event": [
{
"listen": "test",
@@ -2479,6 +2478,74 @@
}
]
},
+ {
+ "name": "Log in Copy 2",
+ "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": "Construction Submission",
"event": [
@@ -2766,7 +2833,6 @@
},
{
"key": "Content-Type",
- "name": "Content-Type",
"value": "application/json",
"type": "text"
}
@@ -2901,7 +2967,6 @@
},
{
"key": "Content-Type",
- "name": "Content-Type",
"value": "application/x-www-form-urlencoded",
"type": "text"
}
@@ -3125,6 +3190,74 @@
{
"name": "Stacking",
"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": "Submission - construction submission",
"event": [
@@ -3611,4 +3744,4 @@
]
}
]
-}
+}
\ No newline at end of file