From 471e181382b4bd7387ab88f29aa9f780728b7fa5 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Thu, 19 Dec 2024 20:30:13 +0000 Subject: [PATCH] Added label upload view --- backend/core/views.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/backend/core/views.py b/backend/core/views.py index 3b224a2a..652996f7 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -437,6 +437,7 @@ def validate_geojson(self, geojson_data): # Validate the first feature with the serializer first_feature["properties"]["aoi"] = self.kwargs.get("aoi_id") serializer = LabelSerializer(data=first_feature) + if not serializer.is_valid(): raise ValidationError(serializer.errors) @@ -447,16 +448,8 @@ def process_labels_geojson(geojson_data, aoi_id): obj.label_status = AOI.DownloadStatus.RUNNING obj.save() for feature in geojson_data["features"]: - geom = feature["geometry"] - # properties = feature["properties"] feature["properties"]["aoi"] = aoi_id - # label_data = {"aoi": aoi_id, "geom": geom, **properties} - - existing_label = Label.objects.filter(aoi=aoi_id, geom=geom).first() - if existing_label: - serializer = LabelSerializer(existing_label, data=feature) - else: - serializer = LabelSerializer(data=feature) + serializer = LabelSerializer(data=feature) if serializer.is_valid(): serializer.save()