From e88a3477d475de68cc1d923faecd271986bc24ad Mon Sep 17 00:00:00 2001 From: shrouxm Date: Thu, 8 Feb 2024 15:34:25 -0800 Subject: [PATCH] feat: color photo conditions fields --- .../apps/graphql/schema/schema.graphql | 22 +++++++++++++++ .../apps/soil_id/graphql/soil_data.py | 12 +++++++++ ...color_photo_lighting_condition_and_more.py | 27 +++++++++++++++++++ .../models/depth_dependent_soil_data.py | 12 +++++++++ 4 files changed, 73 insertions(+) create mode 100644 terraso_backend/apps/soil_id/migrations/0010_depthdependentsoildata_color_photo_lighting_condition_and_more.py diff --git a/terraso_backend/apps/graphql/schema/schema.graphql b/terraso_backend/apps/graphql/schema/schema.graphql index 86acc72f9..bcc577ef3 100644 --- a/terraso_backend/apps/graphql/schema/schema.graphql +++ b/terraso_backend/apps/graphql/schema/schema.graphql @@ -1117,6 +1117,8 @@ type DepthDependentSoilDataNode { colorHue: SoilIdDepthDependentSoilDataColorHueChoices colorValue: SoilIdDepthDependentSoilDataColorValueChoices colorChroma: SoilIdDepthDependentSoilDataColorChromaChoices + colorPhotoSoilCondition: SoilIdDepthDependentSoilDataColorPhotoSoilConditionChoices + colorPhotoLightingCondition: SoilIdDepthDependentSoilDataColorPhotoLightingConditionChoices conductivity: Decimal conductivityTest: SoilIdDepthDependentSoilDataConductivityTestChoices conductivityUnit: SoilIdDepthDependentSoilDataConductivityUnitChoices @@ -1290,6 +1292,24 @@ enum SoilIdDepthDependentSoilDataColorChromaChoices { CHROMA_8 } +"""An enumeration.""" +enum SoilIdDepthDependentSoilDataColorPhotoSoilConditionChoices { + """Moist""" + MOIST + + """Dry""" + DRY +} + +"""An enumeration.""" +enum SoilIdDepthDependentSoilDataColorPhotoLightingConditionChoices { + """Even""" + EVEN + + """Uneven""" + UNEVEN +} + """The `Decimal` scalar type represents a python Decimal.""" scalar Decimal @@ -2258,6 +2278,8 @@ input DepthDependentSoilDataUpdateMutationInput { colorHue: SoilIdDepthDependentSoilDataColorHueChoices colorValue: SoilIdDepthDependentSoilDataColorValueChoices colorChroma: SoilIdDepthDependentSoilDataColorChromaChoices + colorPhotoSoilCondition: SoilIdDepthDependentSoilDataColorPhotoSoilConditionChoices + colorPhotoLightingCondition: SoilIdDepthDependentSoilDataColorPhotoLightingConditionChoices conductivity: Decimal conductivityTest: SoilIdDepthDependentSoilDataConductivityTestChoices conductivityUnit: SoilIdDepthDependentSoilDataConductivityUnitChoices diff --git a/terraso_backend/apps/soil_id/graphql/soil_data.py b/terraso_backend/apps/soil_id/graphql/soil_data.py index b0785bc09..3d04108f1 100644 --- a/terraso_backend/apps/soil_id/graphql/soil_data.py +++ b/terraso_backend/apps/soil_id/graphql/soil_data.py @@ -192,6 +192,14 @@ def color_value_enum(cls): def color_chroma_enum(cls): return cls._meta.fields["color_chroma"].type() + @classmethod + def color_photo_soil_condition_enum(cls): + return cls._meta.fields["color_photo_soil_condition"].type() + + @classmethod + def color_photo_lighting_condition_enum(cls): + return cls._meta.fields["color_photo_lighting_condition"].type() + @classmethod def conductivity_test_enum(cls): return cls._meta.fields["conductivity_test"].type() @@ -393,6 +401,10 @@ class Input: color_hue = DepthDependentSoilDataNode.color_hue_enum() color_value = DepthDependentSoilDataNode.color_value_enum() color_chroma = DepthDependentSoilDataNode.color_chroma_enum() + color_photo_soil_condition = DepthDependentSoilDataNode.color_photo_soil_condition_enum() + color_photo_lighting_condition = ( + DepthDependentSoilDataNode.color_photo_lighting_condition_enum() + ) conductivity = graphene.Decimal() conductivity_test = DepthDependentSoilDataNode.conductivity_test_enum() conductivity_unit = DepthDependentSoilDataNode.conductivity_unit_enum() diff --git a/terraso_backend/apps/soil_id/migrations/0010_depthdependentsoildata_color_photo_lighting_condition_and_more.py b/terraso_backend/apps/soil_id/migrations/0010_depthdependentsoildata_color_photo_lighting_condition_and_more.py new file mode 100644 index 000000000..bde292c64 --- /dev/null +++ b/terraso_backend/apps/soil_id/migrations/0010_depthdependentsoildata_color_photo_lighting_condition_and_more.py @@ -0,0 +1,27 @@ +# Generated by Django 5.0.1 on 2024-02-08 23:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("soil_id", "0009_depthdependentsoildata_clay_percent_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="depthdependentsoildata", + name="color_photo_lighting_condition", + field=models.CharField( + blank=True, choices=[("EVEN", "Even"), ("UNEVEN", "Uneven")], null=True + ), + ), + migrations.AddField( + model_name="depthdependentsoildata", + name="color_photo_soil_condition", + field=models.CharField( + blank=True, choices=[("MOIST", "Moist"), ("DRY", "Dry")], 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 a513c0962..7a9bf92ae 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 @@ -106,6 +106,18 @@ class ColorChroma(models.TextChoices): color_chroma = models.CharField(blank=True, null=True, choices=ColorChroma.choices) + class ColorPhotoSoilCondition(models.TextChoices): + MOIST = "MOIST" + DRY = "DRY" + + color_photo_soil_condition = models.CharField(blank=True, null=True, choices = ColorPhotoSoilCondition) + + class ColorPhotoLightingCondition(models.TextChoices): + EVEN = "EVEN" + UNEVEN = "UNEVEN" + + color_photo_lighting_condition = models.CharField(blank=True, null=True, choices = ColorPhotoLightingCondition) + conductivity = models.DecimalField( blank=True, null=True, max_digits=100, decimal_places=2, validators=[MinValueValidator(0)] )