Skip to content

Commit

Permalink
feat: color photo conditions fields
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouxm committed Feb 8, 2024
1 parent 3bb2e70 commit e88a347
Show file tree
Hide file tree
Showing 4 changed files with 73 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,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
),
),
]
12 changes: 12 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,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)]
)
Expand Down

0 comments on commit e88a347

Please sign in to comment.