Skip to content

Commit

Permalink
feat: color photo conditions fields (#1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouxm authored Feb 13, 2024
1 parent 470615d commit a95a868
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
22 changes: 22 additions & 0 deletions terraso_backend/apps/graphql/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,8 @@ type DepthDependentSoilDataNode {
colorHue: SoilIdDepthDependentSoilDataColorHueChoices
colorValue: SoilIdDepthDependentSoilDataColorValueChoices
colorChroma: SoilIdDepthDependentSoilDataColorChromaChoices
colorPhotoSoilCondition: SoilIdDepthDependentSoilDataColorPhotoSoilConditionChoices
colorPhotoLightingCondition: SoilIdDepthDependentSoilDataColorPhotoLightingConditionChoices
conductivity: Decimal
conductivityTest: SoilIdDepthDependentSoilDataConductivityTestChoices
conductivityUnit: SoilIdDepthDependentSoilDataConductivityUnitChoices
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -2258,6 +2278,8 @@ input DepthDependentSoilDataUpdateMutationInput {
colorHue: SoilIdDepthDependentSoilDataColorHueChoices
colorValue: SoilIdDepthDependentSoilDataColorValueChoices
colorChroma: SoilIdDepthDependentSoilDataColorChromaChoices
colorPhotoSoilCondition: SoilIdDepthDependentSoilDataColorPhotoSoilConditionChoices
colorPhotoLightingCondition: SoilIdDepthDependentSoilDataColorPhotoLightingConditionChoices
conductivity: Decimal
conductivityTest: SoilIdDepthDependentSoilDataConductivityTestChoices
conductivityUnit: SoilIdDepthDependentSoilDataConductivityUnitChoices
Expand Down
12 changes: 12 additions & 0 deletions terraso_backend/apps/soil_id/graphql/soil_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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-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
),
),
]
16 changes: 16 additions & 0 deletions terraso_backend/apps/soil_id/models/depth_dependent_soil_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ 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)]
)
Expand Down

0 comments on commit a95a868

Please sign in to comment.