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/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); @@ -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']; @@ -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) { 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