Skip to content

Commit

Permalink
Added label upload view
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Dec 19, 2024
1 parent 3b07c65 commit 471e181
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()

Expand Down

0 comments on commit 471e181

Please sign in to comment.