From c1db042a09a17c5851b33734fdf3e8ac91b4aebb Mon Sep 17 00:00:00 2001 From: "garo (they/them)" <3411715+shrouxm@users.noreply.github.com> Date: Wed, 24 Jan 2024 10:52:42 -0800 Subject: [PATCH] feat: add clay percent field (#1123) --- .../apps/graphql/schema/schema.graphql | 2 + .../apps/soil_id/graphql/soil_data.py | 1 + ...dependentsoildata_clay_percent_and_more.py | 49 +++++++++++++++++++ .../models/depth_dependent_soil_data.py | 4 ++ 4 files changed, 56 insertions(+) create mode 100644 terraso_backend/apps/soil_id/migrations/0009_depthdependentsoildata_clay_percent_and_more.py diff --git a/terraso_backend/apps/graphql/schema/schema.graphql b/terraso_backend/apps/graphql/schema/schema.graphql index 71c1f702e..2f0fb6c2e 100644 --- a/terraso_backend/apps/graphql/schema/schema.graphql +++ b/terraso_backend/apps/graphql/schema/schema.graphql @@ -1111,6 +1111,7 @@ type DepthInterval { type DepthDependentSoilDataNode { texture: SoilIdDepthDependentSoilDataTextureChoices + clayPercent: Int rockFragmentVolume: SoilIdDepthDependentSoilDataRockFragmentVolumeChoices colorHueSubstep: SoilIdDepthDependentSoilDataColorHueSubstepChoices colorHue: SoilIdDepthDependentSoilDataColorHueChoices @@ -2250,6 +2251,7 @@ input DepthDependentSoilDataUpdateMutationInput { siteId: ID! depthInterval: DepthIntervalInput! texture: SoilIdDepthDependentSoilDataTextureChoices + clayPercent: Int rockFragmentVolume: SoilIdDepthDependentSoilDataRockFragmentVolumeChoices colorHueSubstep: SoilIdDepthDependentSoilDataColorHueSubstepChoices colorHue: SoilIdDepthDependentSoilDataColorHueChoices diff --git a/terraso_backend/apps/soil_id/graphql/soil_data.py b/terraso_backend/apps/soil_id/graphql/soil_data.py index 5f8025808..a52dcc6f9 100644 --- a/terraso_backend/apps/soil_id/graphql/soil_data.py +++ b/terraso_backend/apps/soil_id/graphql/soil_data.py @@ -355,6 +355,7 @@ class Input: site_id = graphene.ID(required=True) depth_interval = graphene.Field(DepthIntervalInput, required=True) texture = DepthDependentSoilDataNode.texture_enum() + clay_percent = graphene.Int() rock_fragment_volume = DepthDependentSoilDataNode.rock_fragment_volume_enum() color_hue_substep = DepthDependentSoilDataNode.color_hue_substep_enum() color_hue = DepthDependentSoilDataNode.color_hue_enum() diff --git a/terraso_backend/apps/soil_id/migrations/0009_depthdependentsoildata_clay_percent_and_more.py b/terraso_backend/apps/soil_id/migrations/0009_depthdependentsoildata_clay_percent_and_more.py new file mode 100644 index 000000000..0d9793000 --- /dev/null +++ b/terraso_backend/apps/soil_id/migrations/0009_depthdependentsoildata_clay_percent_and_more.py @@ -0,0 +1,49 @@ +# Copyright © 2024 Technology Matters +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see https://www.gnu.org/licenses/. + +# Generated by Django 5.0.1 on 2024-01-18 01:02 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("soil_id", "0008_soildata_depth_interval_preset"), + ] + + operations = [ + migrations.AddField( + model_name="depthdependentsoildata", + name="clay_percent", + field=models.IntegerField( + blank=True, + null=True, + validators=[ + django.core.validators.MinValueValidator(0), + django.core.validators.MaxValueValidator(100), + ], + ), + ), + migrations.AlterField( + model_name="soildata", + name="depth_interval_preset", + field=models.CharField( + blank=True, + choices=[("LANDPKS", "Landpks"), ("NRCS", "Nrcs"), ("CUSTOM", "Custom")], + null=True, + ), + ), + ] diff --git a/terraso_backend/apps/soil_id/models/depth_dependent_soil_data.py b/terraso_backend/apps/soil_id/models/depth_dependent_soil_data.py index c2532f58d..a513c0962 100644 --- a/terraso_backend/apps/soil_id/models/depth_dependent_soil_data.py +++ b/terraso_backend/apps/soil_id/models/depth_dependent_soil_data.py @@ -46,6 +46,10 @@ class Texture(models.TextChoices): texture = models.CharField(blank=True, null=True, choices=Texture.choices) + clay_percent = models.IntegerField( + blank=True, null=True, validators=[MinValueValidator(0), MaxValueValidator(100)] + ) + class RockFragmentVolume(models.TextChoices): VOLUME_0_1 = "VOLUME_0_1", "0 — 1%" VOLUME_1_15 = "VOLUME_1_15", "1 — 15%"