UPDATE
This commit is contained in:
@@ -168,6 +168,7 @@ class FarmDataUpsertView(APIView):
|
||||
farm_uuid = serializer.validated_data["farm_uuid"]
|
||||
farm_boundary = serializer.validated_data["farm_boundary"]
|
||||
plant_ids = serializer.validated_data.get("plant_ids")
|
||||
irrigation_method_id = serializer.validated_data.get("irrigation_method_id")
|
||||
sensor_payload = serializer.validated_data.get("sensor_payload", {})
|
||||
try:
|
||||
center_location = resolve_center_location_from_boundary(farm_boundary)
|
||||
@@ -210,12 +211,15 @@ class FarmDataUpsertView(APIView):
|
||||
|
||||
farm_data.center_location = center_location
|
||||
farm_data.weather_forecast = weather_forecast
|
||||
if "irrigation_method_id" in serializer.validated_data:
|
||||
farm_data.irrigation_method_id = irrigation_method_id
|
||||
if not created:
|
||||
farm_data.save(
|
||||
update_fields=[
|
||||
"center_location",
|
||||
"weather_forecast",
|
||||
"sensor_payload",
|
||||
"irrigation_method",
|
||||
"updated_at",
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user