diff --git a/api-rework/client/package-lock.json b/api-rework/client/package-lock.json index ba8574be9..87e7a7d85 100644 --- a/api-rework/client/package-lock.json +++ b/api-rework/client/package-lock.json @@ -9,6 +9,8 @@ "version": "0.0.0", "license": "Apache-2.0", "dependencies": { + "@turf/bbox": "7.3.3", + "@turf/centroid": "7.3.3", "esbuild": "^0.27.2", "immer": "^11.1.3", "json-diff-kit": "^1.0.34", @@ -17,6 +19,7 @@ "lodash.clonedeep": "^4.5.0", "lodash.debounce": "^4.0.8", "lodash.throttle": "^4.1.1", + "maplibre": "0.0.1-security", "moment": "^2.30.1", "react": "^19.2.3", "react-dom": "^19.2.3", @@ -2230,6 +2233,63 @@ "dev": true, "license": "MIT" }, + "node_modules/@turf/bbox": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@turf/bbox/-/bbox-7.3.3.tgz", + "integrity": "sha512-1zNO/JUgDp0N+3EG5fG7+8EolE95OW1LD8ur0hRP0JK+lRyN0gAvJT7n1I9pu/NIqTa8x/zXxGRc1dcOdohYkg==", + "license": "MIT", + "dependencies": { + "@turf/helpers": "7.3.3", + "@turf/meta": "7.3.3", + "@types/geojson": "^7946.0.10", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, + "node_modules/@turf/centroid": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@turf/centroid/-/centroid-7.3.3.tgz", + "integrity": "sha512-3vWLnF1CksLk7xTUH11IzOQJ6fOoj7zhuL8M3GTxcKruVkGat/vIm3Ye5b68sDVcE5nFDA2pYjjbL7Rfmn3/GQ==", + "license": "MIT", + "dependencies": { + "@turf/helpers": "7.3.3", + "@turf/meta": "7.3.3", + "@types/geojson": "^7946.0.10", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, + "node_modules/@turf/helpers": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@turf/helpers/-/helpers-7.3.3.tgz", + "integrity": "sha512-9Ias0L1GuZPIzO6sk8jraTEuLJye6n9LYNEdw69ZGOQ6C1IigjxkPW49zmn21aTv1z27vxdVLSS3r+78DB2QnQ==", + "license": "MIT", + "dependencies": { + "@types/geojson": "^7946.0.10", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, + "node_modules/@turf/meta": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@turf/meta/-/meta-7.3.3.tgz", + "integrity": "sha512-Tz1j4h70iFB5SebWWoVv/uL59x4aOngXU+d1xQDXzOCn/O6txnreGVGMcYU362c5F06yqZx38H9UFTQ553lK0w==", + "license": "MIT", + "dependencies": { + "@turf/helpers": "7.3.3", + "@types/geojson": "^7946.0.10", + "tslib": "^2.8.1" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, "node_modules/@tybys/wasm-util": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", @@ -2311,6 +2371,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -6853,6 +6919,11 @@ "node": ">=10" } }, + "node_modules/maplibre": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/maplibre/-/maplibre-0.0.1-security.tgz", + "integrity": "sha512-XawLsomeCq3O+x3IYTlU1QH52m9JvgEZvffgzWZ9P61HdSghJFzLUJjGXvtwV3hEuuZy9v9iSCG7W8pfr8p4Eg==" + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -9335,9 +9406,7 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, - "license": "0BSD", - "optional": true + "license": "0BSD" }, "node_modules/type-check": { "version": "0.4.0", diff --git a/api-rework/client/package.json b/api-rework/client/package.json index d29dc5623..0015b7336 100644 --- a/api-rework/client/package.json +++ b/api-rework/client/package.json @@ -13,6 +13,8 @@ "npm": ">= 6.0.0" }, "dependencies": { + "@turf/bbox": "7.3.3", + "@turf/centroid": "7.3.3", "esbuild": "^0.27.2", "immer": "^11.1.3", "json-diff-kit": "^1.0.34", @@ -21,6 +23,7 @@ "lodash.clonedeep": "^4.5.0", "lodash.debounce": "^4.0.8", "lodash.throttle": "^4.1.1", + "maplibre": "0.0.1-security", "moment": "^2.30.1", "react": "^19.2.3", "react-dom": "^19.2.3", diff --git a/api-rework/client/src/activities/form-viewer/FormViewer.tsx b/api-rework/client/src/activities/form-viewer/FormViewer.tsx index 1e1648699..8efd028a9 100644 --- a/api-rework/client/src/activities/form-viewer/FormViewer.tsx +++ b/api-rework/client/src/activities/form-viewer/FormViewer.tsx @@ -12,86 +12,106 @@ import AquaticMechTreatment from 'activities/subtypes/AquaticMechTreatment'; import TerrestrialMechTreatment from 'activities/subtypes/TerrestrialMechTreatment'; import TerrestrialChemTreatment from 'activities/subtypes/TerrestrialChemTreatment'; import AquaticChemTreatment from 'activities/subtypes/AquaticChemTreatment'; +import FormMap from 'common-components/form-map/FormMap'; +import DispersalMonitoring from 'activities/subtypes/DispersalMonitoring'; +import BiocontrolCollection from 'activities/subtypes/BiocontrolCollection'; +import BiocontrolRelease from 'activities/subtypes/BiocontrolRelease'; +import { useEffect } from 'react'; -const FormViewer = ({ formData }) => ( -
-
-
- - - - - +const FormViewer = ({ formData }) => { + useEffect(() => { + // Inserts

tags into empty fieldsets where array data would otherwise populate. Used for flagging missing fields + const emptyFieldsets = document.querySelectorAll('fieldset:has(> legend):not(:has(> :not(legend)))'); + emptyFieldsets.forEach((f) => (f.innerHTML += '

NO DATA')); + }, []); + + return ( +

+
+
+ + + + + + + + + + + + + + + +
+
+ {formData?.projects.map(({ description }) => ( + + ))} +
+
+ {formData?.employer.map(({ employer }) => ( + + ))} +
+
+ {formData?.funding_agencies.map(({ invasive_species_agency_code }) => ( + + ))} +
+
+ {formData?.jurisdictions.map(({ jurisdiction, percent_covered }) => ( +
+ + +
+ ))} +
+
+ {formData?.participants.map(({ name, pac_number }) => ( +
+ {pac_number && } + +
+ ))} +
+
+ {formData?.linked_activities?.map(({ full, short_id }) => ( +
+ + +
+ ))} +
+ - - - - - - - - - -
-
- {formData?.projects.map(({ description }) => ( - - ))} -
-
- {formData?.employer.map(({ employer }) => ( - - ))} -
-
- {formData?.funding_agencies.map(({ invasive_species_agency_code }) => ( - - ))} -
-
- {formData?.jurisdictions.map(({ jurisdiction, percent_covered }) => ( -
- - -
- ))} -
-
- {formData?.participants.map(({ name, pac_number }) => ( -
- {pac_number && } - -
- ))} -
-
- {formData?.linked_activities?.map(({ full, short_id }) => ( -
- - -
- ))} -
- - -

Subtype Specific Details

- { +

Subtype Specific Details

{ - Observation_Plant_Terrestrial: , - Observation_Plant_Aquatic: , - Monitoring_Chemical_Plant_Terrestrial_Aquatic: , - Monitoring_Mechanical_Plant_Terrestrial_Aquatic: ( - - ), - Monitoring_Biocontrol_Release_Plant_Terrestrial: , - Treatment_Mechanical_Plant_Terrestrial: , - Treatment_Mechanical_Plant_Aquatic: , - Treatment_Chemical_Plant_Terrestrial: , - Treatment_Chemical_Plant_Aquatic: - }[formData?.subtype] - } + { + Observation_Plant_Terrestrial: , + Observation_Plant_Aquatic: , + Monitoring_Chemical_Plant_Terrestrial_Aquatic: , + Monitoring_Mechanical_Plant_Terrestrial_Aquatic: ( + + ), + Monitoring_Biocontrol_Release_Plant_Terrestrial: , + Treatment_Mechanical_Plant_Terrestrial: , + Treatment_Mechanical_Plant_Aquatic: , + Treatment_Chemical_Plant_Terrestrial: , + Treatment_Chemical_Plant_Aquatic: , + Monitoring_Biocontrol_Dispersal_Plant_Terrestrial: ( + + ), + Biocontrol_Collection: , + Biocontrol_Release: + }[formData?.subtype] + } +
- -); + ); +}; export default FormViewer; diff --git a/api-rework/client/src/activities/subtypes/AquaticChemTreatment.tsx b/api-rework/client/src/activities/subtypes/AquaticChemTreatment.tsx index 5b2d89382..d2465da44 100644 --- a/api-rework/client/src/activities/subtypes/AquaticChemTreatment.tsx +++ b/api-rework/client/src/activities/subtypes/AquaticChemTreatment.tsx @@ -8,7 +8,7 @@ const AquaticChemTreatment = ({ subtypeData }: SubtypeData) => { <>
- +
); diff --git a/api-rework/client/src/activities/subtypes/AquaticMechTreatment.tsx b/api-rework/client/src/activities/subtypes/AquaticMechTreatment.tsx index 297aec29a..0707e738d 100644 --- a/api-rework/client/src/activities/subtypes/AquaticMechTreatment.tsx +++ b/api-rework/client/src/activities/subtypes/AquaticMechTreatment.tsx @@ -18,7 +18,7 @@ const AquaticMechTreatment = ({ subtypeData }: SubtypeData) => ( ))} - + ); diff --git a/api-rework/client/src/activities/subtypes/AquaticObservation.tsx b/api-rework/client/src/activities/subtypes/AquaticObservation.tsx index f1f435e25..b90317fe0 100644 --- a/api-rework/client/src/activities/subtypes/AquaticObservation.tsx +++ b/api-rework/client/src/activities/subtypes/AquaticObservation.tsx @@ -47,7 +47,7 @@ const AquaticObservation = ({ subtypeData }: SubtypeData) => {
- {subtypeData?.observation_details.map((od) => ( + {subtypeData?.entries.map((od) => (
diff --git a/api-rework/client/src/activities/subtypes/BiocontrolCollection.tsx b/api-rework/client/src/activities/subtypes/BiocontrolCollection.tsx new file mode 100644 index 000000000..2a16d016a --- /dev/null +++ b/api-rework/client/src/activities/subtypes/BiocontrolCollection.tsx @@ -0,0 +1,55 @@ +import Fieldset from 'common-components/inputs/Fieldset'; +import MicrositeConditions from './common/MicrositeConditions'; +import TargetPlantPhenology from './common/TargetPlantPhenology'; +import WeatherConditions from './common/WeatherConditions'; +import TextInput from 'common-components/inputs/TextInput'; +import Spacer from 'common-components/inputs/Spacer'; +import TextField from 'common-components/inputs/TextField'; + +const BiocontrolCollection = ({ subtypeData }) => { + return ( + <> + + +
+ {!!subtypeData?.entries?.length &&

No Data

} + {subtypeData?.entries?.map((ci) => ( +
+ + + + + + + + + + + + + +
+ {ci.actual_biological_agents?.map((ba) => ( +
+ + +
+ ))} +
+
+ {ci.estimated_biological_agents?.map((ba) => ( +
+ + +
+ ))} +
+
+ ))} +
+ + + ); +}; + +export default BiocontrolCollection; diff --git a/api-rework/client/src/activities/subtypes/BiocontrolRelease.tsx b/api-rework/client/src/activities/subtypes/BiocontrolRelease.tsx new file mode 100644 index 000000000..f418f5807 --- /dev/null +++ b/api-rework/client/src/activities/subtypes/BiocontrolRelease.tsx @@ -0,0 +1,50 @@ +import { SubtypeData } from 'constants'; +import WeatherConditions from './common/WeatherConditions'; +import MicrositeConditions from './common/MicrositeConditions'; +import TargetPlantPhenology from './common/TargetPlantPhenology'; +import Fieldset from 'common-components/inputs/Fieldset'; +import TextInput from 'common-components/inputs/TextInput'; + +const BiocontrolRelease = ({ subtypeData }: SubtypeData) => { + return ( + <> + + +
+ {!!subtypeData?.entries?.length &&

No Data

} + {subtypeData?.entries?.map((ti) => ( +
+ + + + + + + + + +
+ {ti.actual_biological_agents?.map((ba) => ( +
+ + +
+ ))} +
+
+ {ti.estimated_biological_agents?.map((ba) => ( +
+ + +
+ ))} +
+
+ ))} +
+ + + ); +}; + +export default BiocontrolRelease; diff --git a/api-rework/client/src/activities/subtypes/ChemicalMonitoring.tsx b/api-rework/client/src/activities/subtypes/ChemicalMonitoring.tsx index d6467200f..6200c974f 100644 --- a/api-rework/client/src/activities/subtypes/ChemicalMonitoring.tsx +++ b/api-rework/client/src/activities/subtypes/ChemicalMonitoring.tsx @@ -4,12 +4,11 @@ import MonitoringInfo from './common/MonitoringInfo'; import NearestWells from './common/NearestWells'; const ChemicalMonitoring = ({ subtypeData }: SubtypeData) => { - console.log(subtypeData); return ( <> - +
- {subtypeData?.treatment_monitoring_information?.map((d) => ( + {subtypeData?.entries?.map((d) => ( ))}
diff --git a/api-rework/client/src/activities/subtypes/DispersalMonitoring.tsx b/api-rework/client/src/activities/subtypes/DispersalMonitoring.tsx new file mode 100644 index 000000000..3a628ef4c --- /dev/null +++ b/api-rework/client/src/activities/subtypes/DispersalMonitoring.tsx @@ -0,0 +1,18 @@ +import { SubtypeData } from 'constants'; +import BiocontrolMonitoring from './common/BiocontrolMonitoring'; +import WeatherConditions from './common/WeatherConditions'; +import TargetPlantPhenology from './common/TargetPlantPhenology'; +import MicrositeConditions from './common/MicrositeConditions'; + +const DispersalMonitoring = ({ subtypeData }: SubtypeData) => { + return ( + <> + + + + + + ); +}; + +export default DispersalMonitoring; diff --git a/api-rework/client/src/activities/subtypes/MechanicalMonitoring.tsx b/api-rework/client/src/activities/subtypes/MechanicalMonitoring.tsx index 48b1234a6..2dbe1db74 100644 --- a/api-rework/client/src/activities/subtypes/MechanicalMonitoring.tsx +++ b/api-rework/client/src/activities/subtypes/MechanicalMonitoring.tsx @@ -4,7 +4,7 @@ import MonitoringInfo from './common/MonitoringInfo'; const MechanicalMonitoring = ({ subtypeData }: SubtypeData) => (
- {subtypeData?.treatment_monitoring_information?.map((d) => ( + {subtypeData?.entries?.map((d) => ( ))}
diff --git a/api-rework/client/src/activities/subtypes/ReleaseMonitoring.tsx b/api-rework/client/src/activities/subtypes/ReleaseMonitoring.tsx index a070cfaaa..5bd3ece0c 100644 --- a/api-rework/client/src/activities/subtypes/ReleaseMonitoring.tsx +++ b/api-rework/client/src/activities/subtypes/ReleaseMonitoring.tsx @@ -3,14 +3,12 @@ import TextInput from 'common-components/inputs/TextInput'; import { SubtypeData } from 'constants'; import BiocontrolMonitoring from './common/BiocontrolMonitoring'; import TargetPlantPhenology from './common/TargetPlantPhenology'; +import MicrositeConditions from './common/MicrositeConditions'; const ReleaseMonitoring = ({ subtypeData }: SubtypeData) => ( <> -
- - -
- + +
{ <>
- +
); diff --git a/api-rework/client/src/activities/subtypes/TerrestrialMechTreatment.tsx b/api-rework/client/src/activities/subtypes/TerrestrialMechTreatment.tsx index b0bc9e782..06ba43db2 100644 --- a/api-rework/client/src/activities/subtypes/TerrestrialMechTreatment.tsx +++ b/api-rework/client/src/activities/subtypes/TerrestrialMechTreatment.tsx @@ -1,7 +1,5 @@ import { SubtypeData } from 'constants'; import MechTreatmentInfo from './common/MechTreatmentInfo'; -const TerrestrialMechTreatment = ({ subtypeData }: SubtypeData) => ( - -); +const TerrestrialMechTreatment = ({ subtypeData }: SubtypeData) => ; export default TerrestrialMechTreatment; diff --git a/api-rework/client/src/activities/subtypes/TerrestrialObservation.tsx b/api-rework/client/src/activities/subtypes/TerrestrialObservation.tsx index aee3c9cd6..15a48f4c8 100644 --- a/api-rework/client/src/activities/subtypes/TerrestrialObservation.tsx +++ b/api-rework/client/src/activities/subtypes/TerrestrialObservation.tsx @@ -3,29 +3,20 @@ import TextInput from 'common-components/inputs/TextInput'; import { SubtypeData } from 'constants'; const TerrestrialObservation = ({ subtypeData }: SubtypeData) => { - const BLANK = 'N/A'; + console.log(subtypeData); return ( <>
- - - - + + + +
- {subtypeData?.observation_details.map((od) => ( + {subtypeData?.entries.map((od) => (
diff --git a/api-rework/client/src/activities/subtypes/common/BiocontrolMonitoring.tsx b/api-rework/client/src/activities/subtypes/common/BiocontrolMonitoring.tsx index db4fa86c6..637c074f9 100644 --- a/api-rework/client/src/activities/subtypes/common/BiocontrolMonitoring.tsx +++ b/api-rework/client/src/activities/subtypes/common/BiocontrolMonitoring.tsx @@ -3,9 +3,9 @@ import Fieldset from 'common-components/inputs/Fieldset'; import Spacer from 'common-components/inputs/Spacer'; import TextInput from 'common-components/inputs/TextInput'; -const BiocontrolMonitoring = ({ monitoring_information }) => ( +const BiocontrolMonitoring = ({ entries }) => (
- {monitoring_information.map((mi) => ( + {entries.map((mi) => (
diff --git a/api-rework/client/src/activities/subtypes/common/ChemTreatmentInfo.tsx b/api-rework/client/src/activities/subtypes/common/ChemTreatmentInfo.tsx index 237e0dbce..e79ac438e 100644 --- a/api-rework/client/src/activities/subtypes/common/ChemTreatmentInfo.tsx +++ b/api-rework/client/src/activities/subtypes/common/ChemTreatmentInfo.tsx @@ -6,7 +6,7 @@ import Fieldset from 'common-components/inputs/Fieldset'; const ChemTreatmentInfo = ({ subtypeData }: SubtypeData) => { return ( <> - +
diff --git a/api-rework/client/src/activities/subtypes/common/MechTreatmentInfo.tsx b/api-rework/client/src/activities/subtypes/common/MechTreatmentInfo.tsx index 36269815c..2ee41d2d8 100644 --- a/api-rework/client/src/activities/subtypes/common/MechTreatmentInfo.tsx +++ b/api-rework/client/src/activities/subtypes/common/MechTreatmentInfo.tsx @@ -1,9 +1,9 @@ import Fieldset from 'common-components/inputs/Fieldset'; import TextInput from 'common-components/inputs/TextInput'; -const MechTreatmentInfo = ({ treatmentInfo }) => ( +const MechTreatmentInfo = ({ entries }) => (
- {treatmentInfo?.map((ti) => ( + {entries?.map((ti) => (
diff --git a/api-rework/client/src/activities/subtypes/common/MicrositeConditions.tsx b/api-rework/client/src/activities/subtypes/common/MicrositeConditions.tsx new file mode 100644 index 000000000..534e5063c --- /dev/null +++ b/api-rework/client/src/activities/subtypes/common/MicrositeConditions.tsx @@ -0,0 +1,12 @@ +import Fieldset from 'common-components/inputs/Fieldset'; +import TextInput from 'common-components/inputs/TextInput'; + +const MicrositeConditions = ({ microsite_conditions }) => { + return ( +
+ + +
+ ); +}; +export default MicrositeConditions; diff --git a/api-rework/client/src/activities/subtypes/common/TargetPlantPhenology.tsx b/api-rework/client/src/activities/subtypes/common/TargetPlantPhenology.tsx index 47d265556..c9e96e1a1 100644 --- a/api-rework/client/src/activities/subtypes/common/TargetPlantPhenology.tsx +++ b/api-rework/client/src/activities/subtypes/common/TargetPlantPhenology.tsx @@ -3,15 +3,15 @@ import TextInput from 'common-components/inputs/TextInput'; const TargetPlantPhenology = ({ targetPlantPhenology }) => (
- - - - - - - + + + + + + +
- {targetPlantPhenology.target_plant_heights.map((h) => ( + {targetPlantPhenology?.target_plant_heights.map((h) => ( ))}
diff --git a/api-rework/client/src/activities/subtypes/common/WeatherConditions.tsx b/api-rework/client/src/activities/subtypes/common/WeatherConditions.tsx new file mode 100644 index 000000000..690847307 --- /dev/null +++ b/api-rework/client/src/activities/subtypes/common/WeatherConditions.tsx @@ -0,0 +1,18 @@ +import Fieldset from 'common-components/inputs/Fieldset'; +import TextInput from 'common-components/inputs/TextInput'; +import { SubtypeData } from 'constants'; + +const WeatherConditions = ({ subtypeData }: SubtypeData) => { + return ( +
+ + + + + + +
+ ); +}; + +export default WeatherConditions; diff --git a/api-rework/client/src/common-components/form-map/FormMap.tsx b/api-rework/client/src/common-components/form-map/FormMap.tsx new file mode 100644 index 000000000..623025ebd --- /dev/null +++ b/api-rework/client/src/common-components/form-map/FormMap.tsx @@ -0,0 +1,83 @@ +import { useEffect, useRef, useState } from 'react'; +import maplibregl, { LngLatBoundsLike, LngLatLike } from 'maplibre-gl'; +import { centroid } from '@turf/centroid'; +import { bbox } from '@turf/bbox'; + +import './formMap.css'; + +type PropTypes = { + geojson?: GeoJSON.Polygon | GeoJSON.Feature; +}; +const FormMap = ({ geojson }: PropTypes) => { + const SRC = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'; + const mapRef = useRef(null); + const [map, setMap] = useState(); + + const mapCenter: LngLatLike = (() => { + if (!geojson) return [-121, 54] as LngLatLike; + else return centroid(geojson).geometry.coordinates as LngLatLike; + })(); + + useEffect(() => { + // Init Map after load + setMap( + new maplibregl.Map({ + container: 'map', + center: mapCenter, + zoom: 8, + style: { + sources: { + 'raster-tiles': { + type: 'raster', + tiles: [SRC], + tileSize: 256 + } + }, + layers: [ + { + id: 'raster-tiles', + type: 'raster', + source: 'raster-tiles' + } + ], + version: 8 + } + }) + ); + }, []); + + useEffect(() => { + // Apply Geometry + Layer + if (!map || !geojson) return; + map?.on('load', () => { + if (geojson) { + map?.addSource('form-feature', { + type: 'geojson', + data: geojson + }); + map?.addLayer({ + id: 'form-feature', + type: 'fill', + source: 'form-feature', + layout: {}, + paint: { + 'fill-color': 'orange', + 'fill-opacity': 0.6 + } + }); + const bounds = bbox(geojson) as LngLatBoundsLike; + map.fitBounds(bounds, { + padding: 10, + minZoom: 8 + }); + } + }); + }, [map]); + return ( +
+
+
+ ); +}; + +export default FormMap; diff --git a/api-rework/client/src/common-components/form-map/formMap.css b/api-rework/client/src/common-components/form-map/formMap.css new file mode 100644 index 000000000..38402ffa2 --- /dev/null +++ b/api-rework/client/src/common-components/form-map/formMap.css @@ -0,0 +1,6 @@ +#map { + height: 400px; + width: 400px; + border: 1px solid black; + overflow: hidden; +} diff --git a/api-rework/invasives/api/serializers/common/__init__.py b/api-rework/invasives/api/serializers/common/__init__.py index 388c0e3a4..0f371ee78 100644 --- a/api-rework/invasives/api/serializers/common/__init__.py +++ b/api-rework/invasives/api/serializers/common/__init__.py @@ -1,6 +1,6 @@ from .shoreline_type import ShorelineTypesSerializer from .treatment_monitoring_information import ( - TreatmentMonitoringInfoSerializer, + TreatmentMonitoringEntriesSerializer, AquaticMechanicalMonitoringSerializer, TerrestrialTreatmentMonitoringSerializer, AquaticInvasivePlantOnSiteSerializer, @@ -16,6 +16,6 @@ from .weather_conditions import WeatherConditionsSerializer from .spread_results import SpreadResultsSerializer from .biocontrol_dispersal_monitoring_information import ( - TerrestrialBiologicalMonitoringInformationSerializer, + TerrestrialBiologicalMonitoringEntriesSerializer, ) -from .chemical_treatment_information import ChemicalTreatmentInformationSerializer +from .chemical_treatment_information import ChemicalTreatmentContextSerializer diff --git a/api-rework/invasives/api/serializers/common/biocontrol_dispersal_monitoring_information.py b/api-rework/invasives/api/serializers/common/biocontrol_dispersal_monitoring_information.py index 02760f8c1..5ff13c1dd 100644 --- a/api-rework/invasives/api/serializers/common/biocontrol_dispersal_monitoring_information.py +++ b/api-rework/invasives/api/serializers/common/biocontrol_dispersal_monitoring_information.py @@ -27,7 +27,7 @@ def to_representation(self, instance): return super().to_representation(instance)["location_agent_found"] -class TerrestrialBiologicalMonitoringInformationSerializer(serializers.ModelSerializer): +class TerrestrialBiologicalMonitoringEntriesSerializer(serializers.ModelSerializer): """Serializer for Biocontrol Dispersal/Release Monitoring records""" biocontrol_present = serializers.SerializerMethodField() diff --git a/api-rework/invasives/api/serializers/common/chemical_treatment_information.py b/api-rework/invasives/api/serializers/common/chemical_treatment_information.py index 14e3d212f..66d274e48 100644 --- a/api-rework/invasives/api/serializers/common/chemical_treatment_information.py +++ b/api-rework/invasives/api/serializers/common/chemical_treatment_information.py @@ -2,7 +2,7 @@ from api.models.activity import ChemTreatment -class ChemicalTreatmentInformationSerializer(serializers.ModelSerializer): +class ChemicalTreatmentContextSerializer(serializers.ModelSerializer): class Meta: model = ChemTreatment fields = ( diff --git a/api-rework/invasives/api/serializers/common/treatment_monitoring_information.py b/api-rework/invasives/api/serializers/common/treatment_monitoring_information.py index 68d75809b..b997ab6ac 100644 --- a/api-rework/invasives/api/serializers/common/treatment_monitoring_information.py +++ b/api-rework/invasives/api/serializers/common/treatment_monitoring_information.py @@ -103,7 +103,7 @@ def to_representation(self, instance): return ret -class TreatmentMonitoringInfoSerializer(serializers.Serializer): +class TreatmentMonitoringEntriesSerializer(serializers.Serializer): """Shared Between Mechanical and Chemical Treatments""" a_monitoring_information = AquaticMechanicalMonitoringSerializer( @@ -123,12 +123,12 @@ def to_representation(self, instance): ret = super().to_representation(instance) am = ret.pop("a_monitoring_information", []) tm = ret.pop("t_monitoring_information", []) - ret.update({"treatment_monitoring_information": am + tm}) + ret.update({"entries": am + tm}) return ret def to_internal_value(self, data): """Split incoming list into respective models, normalize aquatic plant key to consistent generic in DB""" - items = data.get("treatment_monitoring_information", []) + items = data.get("entries", []) a_items = [] t_items = [] errors = {} @@ -158,9 +158,7 @@ def to_internal_value(self, data): errors[idx] = serializer.errors if errors: - raise serializers.ValidationError( - {"treatmentmonitoring_information": errors} - ) + raise serializers.ValidationError({"entries": errors}) return { "aquatictreatmentmonitoringinformation_set": a_items, "terrestrialtreatmentmonitoringinformation_set": t_items, diff --git a/api-rework/invasives/api/serializers/type/subtype/aquatic_chemical_treatment.py b/api-rework/invasives/api/serializers/type/subtype/aquatic_chemical_treatment.py index 4aa67560f..91bc2e543 100644 --- a/api-rework/invasives/api/serializers/type/subtype/aquatic_chemical_treatment.py +++ b/api-rework/invasives/api/serializers/type/subtype/aquatic_chemical_treatment.py @@ -1,22 +1,22 @@ from rest_framework import serializers from api.serializers.common import ( NearestWellSerializer, - ChemicalTreatmentInformationSerializer, + ChemicalTreatmentContextSerializer, ) class AquaticChemicalTreatmentSerializer(serializers.Serializer): - chem_treatment = ChemicalTreatmentInformationSerializer(source="chemtreatment") - well_information = NearestWellSerializer(source="nearestwell_set", many=True) - chem_treatment_details = serializers.SerializerMethodField() + context = ChemicalTreatmentContextSerializer(source="chemtreatment") + well_entries = NearestWellSerializer(source="nearestwell_set", many=True) + entries = serializers.SerializerMethodField() - def get_chem_treatment_details(self, obj): + def get_entries(self, obj): # TODO: return "NOT IMPLEMENTED" def to_representation(self, instance): ret = super().to_representation(instance) - info_data = ret.pop("chem_treatment", None) + info_data = ret.pop("context", None) if info_data and isinstance(info_data, dict): ret.update(info_data) return ret diff --git a/api-rework/invasives/api/serializers/type/subtype/aquatic_mechanical_treatment.py b/api-rework/invasives/api/serializers/type/subtype/aquatic_mechanical_treatment.py index 64825f500..a69de9f5f 100644 --- a/api-rework/invasives/api/serializers/type/subtype/aquatic_mechanical_treatment.py +++ b/api-rework/invasives/api/serializers/type/subtype/aquatic_mechanical_treatment.py @@ -17,7 +17,7 @@ class Meta: class AquaticPlantTreatmentMechanicalSerializer(serializers.Serializer): - mechanical_treatments = AquaticPlantMechanicalTreatmentSerializer( + entries = AquaticPlantMechanicalTreatmentSerializer( source="aquaticplantmechanicaltreatment_set", many=True ) authorization_info = serializers.CharField( diff --git a/api-rework/invasives/api/serializers/type/subtype/aquatic_observation.py b/api-rework/invasives/api/serializers/type/subtype/aquatic_observation.py index e7019041e..a0ceafb01 100644 --- a/api-rework/invasives/api/serializers/type/subtype/aquatic_observation.py +++ b/api-rework/invasives/api/serializers/type/subtype/aquatic_observation.py @@ -169,7 +169,7 @@ class AquaticObservationSerializer(serializers.Serializer): adjacent_land_use = WaterbodyAdjacentLandUseSerializer( source="waterbodyadjacentlanduse_set", many=True ) - observation_details = AquaticPlantObservationDetailSerializer( + entries = AquaticPlantObservationDetailSerializer( source="aquaticplantobservationdetail_set", many=True ) pretreatment_observation = serializers.CharField( @@ -182,8 +182,8 @@ class AquaticObservationSerializer(serializers.Serializer): # suitable_for_biocontrol = serializers.CharField( # source="suitableforbiocontrol.suitable_for_biocontrol" # ) - waterbody_details = WaterbodyDataSerializer(source="waterbodydata") - waterbody_use = WaterbodyUseSerializer(source="waterbodyuse_set", many=True) + waterbody_context = WaterbodyDataSerializer(source="waterbodydata") + water_use = WaterbodyUseSerializer(source="waterbodyuse_set", many=True) waterlevel_management = WaterbodyLevelManagementSerializer( source="waterbodylevelmanagement_set", many=True ) @@ -206,7 +206,7 @@ class AquaticObservationSerializer(serializers.Serializer): def to_representation(self, instance): """Flatten Waterbody Details into top_level""" ret = super().to_representation(instance) - info_data = ret.pop("waterbody_details", None) + info_data = ret.pop("waterbody_context", None) if info_data and isinstance(info_data, dict): ret.update(info_data) diff --git a/api-rework/invasives/api/serializers/type/subtype/biocontrol_collection.py b/api-rework/invasives/api/serializers/type/subtype/biocontrol_collection.py index db2c5976a..f099897a5 100644 --- a/api-rework/invasives/api/serializers/type/subtype/biocontrol_collection.py +++ b/api-rework/invasives/api/serializers/type/subtype/biocontrol_collection.py @@ -58,7 +58,7 @@ class BiocontrolCollectionSerializer(serializers.Serializer): target_plant_phenology = TargetPlantPhenologySerializer( source="targetplantphenology" ) - collection_information = TerrestrialBiocontrolCollectionInfoSerializer( + entries = TerrestrialBiocontrolCollectionInfoSerializer( source="terrestrialbiocontrolcollectioninformation_set", many=True ) diff --git a/api-rework/invasives/api/serializers/type/subtype/biocontrol_dispersal_monitoring.py b/api-rework/invasives/api/serializers/type/subtype/biocontrol_dispersal_monitoring.py index 9b9e4e009..1122633da 100644 --- a/api-rework/invasives/api/serializers/type/subtype/biocontrol_dispersal_monitoring.py +++ b/api-rework/invasives/api/serializers/type/subtype/biocontrol_dispersal_monitoring.py @@ -1,7 +1,7 @@ from rest_framework import serializers from api.serializers.common import ( MicrositeConditionSerializer, - TerrestrialBiologicalMonitoringInformationSerializer, + TerrestrialBiologicalMonitoringEntriesSerializer, TargetPlantPhenologySerializer, WeatherConditionsSerializer, ) @@ -9,7 +9,7 @@ class BiocontrolDispersalMonitoringSerializer(serializers.Serializer): microsite_condition = MicrositeConditionSerializer(source="micrositecondition") - monitoring_information = TerrestrialBiologicalMonitoringInformationSerializer( + entries = TerrestrialBiologicalMonitoringEntriesSerializer( source="terrestrialbiocontroldispersalmonitoring_set", many=True ) target_plant_phenology = TargetPlantPhenologySerializer( diff --git a/api-rework/invasives/api/serializers/type/subtype/biocontrol_release.py b/api-rework/invasives/api/serializers/type/subtype/biocontrol_release.py index def44e6f7..b4aa54d2e 100644 --- a/api-rework/invasives/api/serializers/type/subtype/biocontrol_release.py +++ b/api-rework/invasives/api/serializers/type/subtype/biocontrol_release.py @@ -50,7 +50,7 @@ def get_estimated_biological_agents(self, obj): class BiocontrolReleaseSerializer(serializers.Serializer): - treatment_information = TerrestrialBiocontrolReleaseSerializer( + entries = TerrestrialBiocontrolReleaseSerializer( source="terrestrialbiocontrolrelease_set", many=True ) target_plant_phenology = TargetPlantPhenologySerializer( diff --git a/api-rework/invasives/api/serializers/type/subtype/biocontrol_release_monitoring.py b/api-rework/invasives/api/serializers/type/subtype/biocontrol_release_monitoring.py index 42fdec881..4d0453518 100644 --- a/api-rework/invasives/api/serializers/type/subtype/biocontrol_release_monitoring.py +++ b/api-rework/invasives/api/serializers/type/subtype/biocontrol_release_monitoring.py @@ -1,7 +1,7 @@ from rest_framework import serializers from api.serializers.common import ( MicrositeConditionSerializer, - TerrestrialBiologicalMonitoringInformationSerializer, + TerrestrialBiologicalMonitoringEntriesSerializer, TargetPlantPhenologySerializer, SpreadResultsSerializer, WeatherConditionsSerializer, @@ -10,7 +10,7 @@ class BiocontrolReleaseMonitoringSerializer(serializers.Serializer): microsite_condition = MicrositeConditionSerializer(source="micrositecondition") - monitoring_information = TerrestrialBiologicalMonitoringInformationSerializer( + entries = TerrestrialBiologicalMonitoringEntriesSerializer( source="terrestrialbiocontroldispersalmonitoring_set", many=True ) target_plant_phenology = TargetPlantPhenologySerializer( diff --git a/api-rework/invasives/api/serializers/type/subtype/chemical_treatment_monitoring.py b/api-rework/invasives/api/serializers/type/subtype/chemical_treatment_monitoring.py index 128ab8b46..354ae5f2a 100644 --- a/api-rework/invasives/api/serializers/type/subtype/chemical_treatment_monitoring.py +++ b/api-rework/invasives/api/serializers/type/subtype/chemical_treatment_monitoring.py @@ -1,21 +1,21 @@ from rest_framework import serializers from api.serializers.common import ( - TreatmentMonitoringInfoSerializer, + TreatmentMonitoringEntriesSerializer, NearestWellSerializer, ) class ChemicalMonitoringSerializer(serializers.Serializer): - treatment_monitoring_information = serializers.SerializerMethodField() - nearest_wells = NearestWellSerializer(source="nearestwell_set", many=True) + entries = serializers.SerializerMethodField() + well_entries = NearestWellSerializer(source="nearestwell_set", many=True) - def get_treatment_monitoring_information(self, obj): - return TreatmentMonitoringInfoSerializer(obj, context=self.context).data + def get_entries(self, obj): + return TreatmentMonitoringEntriesSerializer(obj, context=self.context).data def to_representation(self, instance): """Flatten""" ret = super().to_representation(instance) - info_data = ret.pop("treatment_monitoring_information", None) + info_data = ret.pop("entries", None) if info_data and isinstance(info_data, dict): ret.update(info_data) diff --git a/api-rework/invasives/api/serializers/type/subtype/mechanical_treatment_monitoring.py b/api-rework/invasives/api/serializers/type/subtype/mechanical_treatment_monitoring.py index 7d4019cf6..aa416b28c 100644 --- a/api-rework/invasives/api/serializers/type/subtype/mechanical_treatment_monitoring.py +++ b/api-rework/invasives/api/serializers/type/subtype/mechanical_treatment_monitoring.py @@ -1,17 +1,17 @@ from rest_framework import serializers -from api.serializers.common import TreatmentMonitoringInfoSerializer +from api.serializers.common import TreatmentMonitoringEntriesSerializer class MechanicalMonitoringSerializer(serializers.Serializer): - treatment_monitoring_information = serializers.SerializerMethodField() + entries = serializers.SerializerMethodField() - def get_treatment_monitoring_information(self, obj): - return TreatmentMonitoringInfoSerializer(obj, context=self.context).data + def get_entries(self, obj): + return TreatmentMonitoringEntriesSerializer(obj, context=self.context).data def to_representation(self, instance): """Flatten""" ret = super().to_representation(instance) - info_data = ret.pop("treatment_monitoring_information", None) + info_data = ret.pop("entries", None) if info_data and isinstance(info_data, dict): ret.update(info_data) diff --git a/api-rework/invasives/api/serializers/type/subtype/terrestrial_chemical_treatment.py b/api-rework/invasives/api/serializers/type/subtype/terrestrial_chemical_treatment.py index cd36b9476..509419a3c 100644 --- a/api-rework/invasives/api/serializers/type/subtype/terrestrial_chemical_treatment.py +++ b/api-rework/invasives/api/serializers/type/subtype/terrestrial_chemical_treatment.py @@ -1,22 +1,22 @@ from rest_framework import serializers from api.serializers.common import ( NearestWellSerializer, - ChemicalTreatmentInformationSerializer, + ChemicalTreatmentContextSerializer, ) class TerrestrialChemicalTreatmentSerializer(serializers.Serializer): - chem_treatment = ChemicalTreatmentInformationSerializer(source="chemtreatment") - well_information = NearestWellSerializer(source="nearestwell_set", many=True) - chem_treatment_details = serializers.SerializerMethodField() + details = ChemicalTreatmentContextSerializer(source="chemtreatment") + well_entries = NearestWellSerializer(source="nearestwell_set", many=True) + entries = serializers.SerializerMethodField() - def get_chem_treatment_details(self, obj): + def get_entries(self, obj): # TODO: return "NOT IMPLEMENTED" def to_representation(self, instance): ret = super().to_representation(instance) - info_data = ret.pop("chem_treatment", None) + info_data = ret.pop("details", None) if info_data and isinstance(info_data, dict): ret.update(info_data) return ret diff --git a/api-rework/invasives/api/serializers/type/subtype/terrestrial_mechanical_treatment.py b/api-rework/invasives/api/serializers/type/subtype/terrestrial_mechanical_treatment.py index dfd8a3429..fbc6691ec 100644 --- a/api-rework/invasives/api/serializers/type/subtype/terrestrial_mechanical_treatment.py +++ b/api-rework/invasives/api/serializers/type/subtype/terrestrial_mechanical_treatment.py @@ -16,6 +16,6 @@ class Meta: class TerrestrialPlantTreatmentMechanicalSerializer(serializers.Serializer): - mechanical_treatments = TerrestrialPlantMechanicalTreatmentSerializer( + entries = TerrestrialPlantMechanicalTreatmentSerializer( source="terrestrialplantmechanicaltreatment_set", many=True ) diff --git a/api-rework/invasives/api/serializers/type/subtype/terrestrial_observation.py b/api-rework/invasives/api/serializers/type/subtype/terrestrial_observation.py index 921023306..ae63243d3 100644 --- a/api-rework/invasives/api/serializers/type/subtype/terrestrial_observation.py +++ b/api-rework/invasives/api/serializers/type/subtype/terrestrial_observation.py @@ -66,7 +66,7 @@ class Meta: ) -class TerrestrialPlantObservationDetailSerializer(serializers.ModelSerializer): +class TerrestrialPlantObservationContextSerializer(serializers.ModelSerializer): voucher_specimen = serializers.SerializerMethodField() class Meta: @@ -97,7 +97,7 @@ def get_voucher_specimen(self, obj): return None -class TerrestrialPlantObservationInfoSerializer(serializers.ModelSerializer): +class TerrestrialPlantObservationEntriesSerializer(serializers.ModelSerializer): specific_use = SpecificUseCodeSerializer() soil_texture = SoilTextureCodeSerializer() aspect = AspectCodeSerializer() @@ -117,10 +117,10 @@ class Meta: class TerrestrialObservationSerializer(serializers.Serializer): - observation_details = TerrestrialPlantObservationDetailSerializer( + entries = TerrestrialPlantObservationContextSerializer( source="terrestrialplantobservationdetail_set", many=True ) - observation_information = TerrestrialPlantObservationInfoSerializer( + context = TerrestrialPlantObservationEntriesSerializer( source="terrestrialplantobservationinfo" ) pretreatment_observation = serializers.CharField( @@ -129,7 +129,7 @@ class TerrestrialObservationSerializer(serializers.Serializer): def to_representation(self, instance): ret = super().to_representation(instance) - info_data = ret.pop("observation_information", None) + info_data = ret.pop("context", None) if info_data and isinstance(info_data, dict): ret.update(info_data) diff --git a/api-rework/invasives/api/tests/subtypes/test_aquatic_chemical_treatment.py b/api-rework/invasives/api/tests/subtypes/test_aquatic_chemical_treatment.py index 7115108e7..54fea52a2 100644 --- a/api-rework/invasives/api/tests/subtypes/test_aquatic_chemical_treatment.py +++ b/api-rework/invasives/api/tests/subtypes/test_aquatic_chemical_treatment.py @@ -18,7 +18,7 @@ def test_pac_number_is_present(self): self.pac_number_is_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer(expected_subtype_key="well_information") + self.casting_fixture_into_serializer(expected_subtype_key="entries") def test_subtype_values(self): record = self.fetch_a().json() @@ -40,13 +40,13 @@ def test_subtype_values(self): self.assertEqual(sd["additional_unmapped_well_water_bool"], True) self.assertEqual(sd["pest_injury_threshold_determination_bool"], True) - wells = sd["well_information"] + wells = sd["well_entries"] self.assertEqual(len(wells), 3) for well in wells: self.assertIsNotNone(well["well_tag_number"]) self.assertIsNotNone(well["distance"]) - if sd["chem_treatment_details"] != "NOT IMPLEMENTED": + if sd["entries"] != "NOT IMPLEMENTED": # TODO self.fail("UPDATE TEST FOR CHEM TREATMENT DETAILS") diff --git a/api-rework/invasives/api/tests/subtypes/test_aquatic_mechanical_treatment.py b/api-rework/invasives/api/tests/subtypes/test_aquatic_mechanical_treatment.py index ba3a5e3f2..b044d3cc6 100644 --- a/api-rework/invasives/api/tests/subtypes/test_aquatic_mechanical_treatment.py +++ b/api-rework/invasives/api/tests/subtypes/test_aquatic_mechanical_treatment.py @@ -17,20 +17,16 @@ def test_no_pac_number_present(self): self.no_pac_number_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer( - expected_subtype_key="mechanical_treatments" - ) + self.casting_fixture_into_serializer(expected_subtype_key="entries") def test_subtype_details_full(self): """Subtype keys match the information from fixtures.""" response_object = self.fetch_a().json() - self.assertEqual( - len(response_object["subtype_data"]["mechanical_treatments"]), 1 - ) + self.assertEqual(len(response_object["subtype_data"]["entries"]), 1) sd = response_object["subtype_data"] - mt = sd["mechanical_treatments"][0] + mt = sd["entries"][0] self.assertEqual(mt["disposed_material_amount"], 544) self.assertEqual(mt["disposed_material_format"], "kg") @@ -53,7 +49,7 @@ def test_subtype_details_two_entries(self): sd = response_object["subtype_data"] self.assertEqual(sd["authorization_info"], "The test looks for this") - mt = sd["mechanical_treatments"] + mt = sd["entries"] self.assertEqual(len(mt), 2) expected = [ diff --git a/api-rework/invasives/api/tests/subtypes/test_aquatic_observation.py b/api-rework/invasives/api/tests/subtypes/test_aquatic_observation.py index 4a7d49699..bd6e67431 100644 --- a/api-rework/invasives/api/tests/subtypes/test_aquatic_observation.py +++ b/api-rework/invasives/api/tests/subtypes/test_aquatic_observation.py @@ -28,13 +28,13 @@ def test_subtype_details_full(self): # self.assertEqual(sd["suitable_for_biocontrol"], "No") self.assertEqual(sd["pretreatment_observation"], "Yes") - self.assertGreaterEqual(len(sd["observation_details"]), 1) + self.assertGreaterEqual(len(sd["entries"]), 1) self.assertIn("WET", sd["inflow_permanent"]) self.assertIn("DISP", sd["inflow_seasonal"]) self.assertIn("WET", sd["outflow_permanent"]) self.assertIn("WET", sd["outflow_seasonal"]) self.assertIn("Dam", sd["waterlevel_management"]) - self.assertIn("AI", sd["waterbody_use"]) + self.assertIn("AI", sd["water_use"]) self.assertIn("GR", sd["substrate_type"]) self.assertIn("H", sd["adjacent_land_use"]) @@ -42,7 +42,7 @@ def test_subtype_details_full(self): self.assertEqual(st["shoreline_type"], "LGA") self.assertEqual(st["percent_covered"], 100) - od = sd["observation_details"][0] + od = sd["entries"][0] self.assertEqual(od["density"], "D") self.assertEqual(od["distribution"], "WS") self.assertEqual(od["invasive_plant"], "JK") @@ -72,7 +72,7 @@ def test_subtype_details_partial(self): # @todo add subtype observation info class # self.assertEqual(sd["suitable_for_biocontrol"], "Yes") self.assertEqual(sd["pretreatment_observation"], "No") - self.assertEqual(len(sd["observation_details"]), 2) + self.assertEqual(len(sd["entries"]), 2) obs_detail = [ { @@ -95,4 +95,4 @@ def test_subtype_details_partial(self): }, ] - self.assertCountEqual(obs_detail, sd["observation_details"]) + self.assertCountEqual(obs_detail, sd["entries"]) diff --git a/api-rework/invasives/api/tests/subtypes/test_biocontrol_collection.py b/api-rework/invasives/api/tests/subtypes/test_biocontrol_collection.py index 74a04dd14..bcf19e85d 100644 --- a/api-rework/invasives/api/tests/subtypes/test_biocontrol_collection.py +++ b/api-rework/invasives/api/tests/subtypes/test_biocontrol_collection.py @@ -17,9 +17,7 @@ def test_no_pac_number_present(self): self.no_pac_number_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer( - expected_subtype_key="collection_information" - ) + self.casting_fixture_into_serializer(expected_subtype_key="entries") def test_subtype_details_full(self): """Subtype keys match the information from fixtures.""" @@ -27,7 +25,7 @@ def test_subtype_details_full(self): sd = response_object["subtype_data"] - ti = sd["collection_information"] + ti = sd["entries"] self.assertEqual(len(ti), 1) ti = ti[0] self.assertEqual(ti["collection_type"], "Timed") diff --git a/api-rework/invasives/api/tests/subtypes/test_biocontrol_dispersal_monitoring.py b/api-rework/invasives/api/tests/subtypes/test_biocontrol_dispersal_monitoring.py index f55260ed3..7667a062a 100644 --- a/api-rework/invasives/api/tests/subtypes/test_biocontrol_dispersal_monitoring.py +++ b/api-rework/invasives/api/tests/subtypes/test_biocontrol_dispersal_monitoring.py @@ -17,16 +17,14 @@ def test_no_pac_number_present(self): self.no_pac_number_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer( - expected_subtype_key="monitoring_information" - ) + self.casting_fixture_into_serializer(expected_subtype_key="entries") def test_subtype_details_full(self): response_object = self.fetch_a().json() sd = response_object["subtype_data"] - mi = sd["monitoring_information"] + mi = sd["entries"] self.assertEqual(len(mi), 1) mi = mi[0] diff --git a/api-rework/invasives/api/tests/subtypes/test_biocontrol_release.py b/api-rework/invasives/api/tests/subtypes/test_biocontrol_release.py index cd85a6a43..f18d9ba2a 100644 --- a/api-rework/invasives/api/tests/subtypes/test_biocontrol_release.py +++ b/api-rework/invasives/api/tests/subtypes/test_biocontrol_release.py @@ -17,9 +17,7 @@ def test_no_pac_number_present(self): self.no_pac_number_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer( - expected_subtype_key="treatment_information" - ) + self.casting_fixture_into_serializer(expected_subtype_key="entries") def test_subtype_details_full(self): """Subtype keys match the information from fixtures.""" @@ -27,7 +25,7 @@ def test_subtype_details_full(self): sd = response_object["subtype_data"] - ti = sd["treatment_information"] + ti = sd["entries"] self.assertEqual(len(ti), 1) ti = ti[0] diff --git a/api-rework/invasives/api/tests/subtypes/test_biocontrol_release_monitoring.py b/api-rework/invasives/api/tests/subtypes/test_biocontrol_release_monitoring.py index 5dac0e838..2626be5d1 100644 --- a/api-rework/invasives/api/tests/subtypes/test_biocontrol_release_monitoring.py +++ b/api-rework/invasives/api/tests/subtypes/test_biocontrol_release_monitoring.py @@ -17,16 +17,14 @@ def test_no_pac_number_present(self): self.no_pac_number_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer( - expected_subtype_key="monitoring_information" - ) + self.casting_fixture_into_serializer(expected_subtype_key="entries") def test_subtype_details_full(self): response_object = self.fetch_a().json() sd = response_object["subtype_data"] - mi = sd["monitoring_information"] + mi = sd["entries"] self.assertEqual(len(mi), 1) mi = mi[0] diff --git a/api-rework/invasives/api/tests/subtypes/test_chemical_treatment_monitoring.py b/api-rework/invasives/api/tests/subtypes/test_chemical_treatment_monitoring.py index 69dab99fb..5023d1776 100644 --- a/api-rework/invasives/api/tests/subtypes/test_chemical_treatment_monitoring.py +++ b/api-rework/invasives/api/tests/subtypes/test_chemical_treatment_monitoring.py @@ -18,15 +18,13 @@ def test_no_pac_number_present(self): self.no_pac_number_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer( - expected_subtype_key="treatment_monitoring_information" - ) + self.casting_fixture_into_serializer(expected_subtype_key="entries") def test_subtype_details_full(self): """Subtype keys match the information from fixtures.""" response_object = self.fetch_a().json() - tmi = response_object["subtype_data"]["treatment_monitoring_information"] + tmi = response_object["subtype_data"]["entries"] self.assertEqual(len(tmi), 1) tmi = tmi[0] self.assertEqual(tmi["comment"], "Several plants remain") @@ -62,14 +60,14 @@ def test_monitoring_info_keys_serialize_out(self): ] response_object = self.fetch_b().json() - tmi = response_object["subtype_data"]["treatment_monitoring_information"] + tmi = response_object["subtype_data"]["entries"] self.assertListEqual(payload, tmi) def test_nearest_wells_present(self): """Tests Wells tied to a Chemical Monitoring Record are present""" response_object = self.fetch_b().json() - nw = response_object["subtype_data"]["nearest_wells"] + nw = response_object["subtype_data"]["well_entries"] self.assertEqual(len(nw), 3) diff --git a/api-rework/invasives/api/tests/subtypes/test_mechanical_treatment_monitoring.py b/api-rework/invasives/api/tests/subtypes/test_mechanical_treatment_monitoring.py index ca3a90d2f..5f7c00f21 100644 --- a/api-rework/invasives/api/tests/subtypes/test_mechanical_treatment_monitoring.py +++ b/api-rework/invasives/api/tests/subtypes/test_mechanical_treatment_monitoring.py @@ -17,14 +17,12 @@ def test_no_pac_number_present(self): self.no_pac_number_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer( - expected_subtype_key="treatment_monitoring_information" - ) + self.casting_fixture_into_serializer(expected_subtype_key="entries") def test_subtype_details_full(self): """Subtype keys match the information from fixtures.""" response_object = self.fetch_a().json() - tmi = response_object["subtype_data"]["treatment_monitoring_information"] + tmi = response_object["subtype_data"]["entries"] self.assertEqual(len(tmi), 1) tmi = tmi[0] self.assertEqual(tmi["comment"], "Several plants remain") @@ -60,5 +58,5 @@ def test_monitoring_info_keys_serialize_out(self): ] response_object = self.fetch_b().json() - tmi = response_object["subtype_data"]["treatment_monitoring_information"] + tmi = response_object["subtype_data"]["entries"] self.assertListEqual(payload, tmi) diff --git a/api-rework/invasives/api/tests/subtypes/test_terrestrial_chemical_treatment.py b/api-rework/invasives/api/tests/subtypes/test_terrestrial_chemical_treatment.py index ef5b68959..98bd39910 100644 --- a/api-rework/invasives/api/tests/subtypes/test_terrestrial_chemical_treatment.py +++ b/api-rework/invasives/api/tests/subtypes/test_terrestrial_chemical_treatment.py @@ -18,7 +18,7 @@ def test_pac_number_is_present(self): self.pac_number_is_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer(expected_subtype_key="well_information") + self.casting_fixture_into_serializer(expected_subtype_key="well_entries") def test_subtype_values(self): record = self.fetch_a().json() @@ -40,13 +40,13 @@ def test_subtype_values(self): self.assertEqual(sd["additional_unmapped_well_water_bool"], True) self.assertEqual(sd["pest_injury_threshold_determination_bool"], True) - wells = sd["well_information"] + wells = sd["well_entries"] self.assertEqual(len(wells), 3) for well in wells: self.assertIsNotNone(well["well_tag_number"]) self.assertIsNotNone(well["distance"]) - if sd["chem_treatment_details"] != "NOT IMPLEMENTED": + if sd["entries"] != "NOT IMPLEMENTED": # TODO self.fail("UPDATE TESTS FOR CHEM TREATMENT DETAILS") diff --git a/api-rework/invasives/api/tests/subtypes/test_terrestrial_mechanical_treatment.py b/api-rework/invasives/api/tests/subtypes/test_terrestrial_mechanical_treatment.py index aefb25dd8..2d4b50df8 100644 --- a/api-rework/invasives/api/tests/subtypes/test_terrestrial_mechanical_treatment.py +++ b/api-rework/invasives/api/tests/subtypes/test_terrestrial_mechanical_treatment.py @@ -17,18 +17,14 @@ def test_no_pac_number_present(self): self.no_pac_number_present() def test_casting_fixture_into_serializer(self): - self.casting_fixture_into_serializer( - expected_subtype_key="mechanical_treatments" - ) + self.casting_fixture_into_serializer(expected_subtype_key="entries") def test_subtype_details_full(self): """Subtype keys match the information from fixtures.""" response_object = self.fetch_a().json() - self.assertEqual( - len(response_object["subtype_data"]["mechanical_treatments"]), 1 - ) + self.assertEqual(len(response_object["subtype_data"]["entries"]), 1) - mt = response_object["subtype_data"]["mechanical_treatments"][0] + mt = response_object["subtype_data"]["entries"][0] self.assertEqual(mt["disposed_material_amount"], 544) self.assertEqual(mt["disposed_material_format"], "kg") self.assertEqual(mt["disposal_method"], "II") @@ -39,7 +35,7 @@ def test_subtype_details_full(self): def test_subtype_details_two_entries(self): """Subtype keys match the information from fixtures.""" response_object = self.fetch_b().json() - mt = response_object["subtype_data"]["mechanical_treatments"] + mt = response_object["subtype_data"]["entries"] self.assertEqual(len(mt), 2) expected = [ diff --git a/api-rework/invasives/api/tests/subtypes/test_terrestrial_observation.py b/api-rework/invasives/api/tests/subtypes/test_terrestrial_observation.py index 2428e8925..edac845e9 100644 --- a/api-rework/invasives/api/tests/subtypes/test_terrestrial_observation.py +++ b/api-rework/invasives/api/tests/subtypes/test_terrestrial_observation.py @@ -33,9 +33,9 @@ def test_subtype_details_full(self): self.assertEqual(sd["slope_percent"]["code"], "SS") self.assertEqual(sd["soil_texture"]["code"], "M") self.assertEqual(sd["pretreatment_observation"], "Yes") - self.assertGreaterEqual(len(sd["observation_details"]), 1) + self.assertGreaterEqual(len(sd["entries"]), 1) - od = sd["observation_details"][0] + od = sd["entries"][0] self.assertEqual(od["density"], "D") self.assertEqual(od["distribution"], "WS") self.assertEqual(od["invasive_plant"], "JK") @@ -68,7 +68,7 @@ def test_subtype_details_partial(self): self.assertEqual(sd["aspect"]["code"], "NA") self.assertEqual(sd["slope_percent"]["code"], "VT") self.assertEqual(sd["soil_texture"]["code"], "F") - self.assertEqual(len(sd["observation_details"]), 2) + self.assertEqual(len(sd["entries"]), 2) obs_detail = [ { @@ -89,4 +89,4 @@ def test_subtype_details_partial(self): }, ] - self.assertCountEqual(obs_detail, sd["observation_details"]) + self.assertCountEqual(obs_detail, sd["entries"])