Skip to content

Commit 62bf209

Browse files
Merge pull request #49 from MTES-MCT/develop
feat: add url column to export
2 parents 0b523d9 + fd44936 commit 62bf209

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

core/views/detection/detection_list.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from aigle.settings.base import DOMAIN
12
from common.views.base import BaseViewSetMixin
23

34
from django_filters import FilterSet, NumberFilter, ChoiceFilter, OrderingFilter
@@ -71,6 +72,7 @@ class DetectionListOverviewSerializer(serializers.Serializer):
7172

7273
DOWNLOAD_FILE_HEADERS = [
7374
"Object n°",
75+
"URL",
7476
"Commune",
7577
"Type",
7678
"Parcelle (section)",
@@ -346,6 +348,7 @@ def download(self, request):
346348
queryset = get_list_values_list(
347349
queryset,
348350
"detection_object__id",
351+
"detection_object__uuid",
349352
"detection_object__commune__name",
350353
"detection_object__object_type__name",
351354
"detection_object__parcel__section",
@@ -463,14 +466,15 @@ def process_rows(results):
463466
combined_data = {}
464467

465468
ID_INDEX = 0
466-
SCORE_INDEX = 5
467-
SOURCE_INDEX = 6
468-
DETECTION_CONTROL_STATUS_INDEX = 7
469-
DETECTION_PRESCRIPTION_STATUS_INDEX = 8
470-
DETECTION_VALIDATION_STATUS_INDEX = 9
471-
TILE_SETS_INDEX = 10
472-
CUSTOM_ZONES_INDEX = 11
473-
GEOMETRY_CENTER_INDEX = 12
469+
UUID_INDEX = 1
470+
SCORE_INDEX = 6
471+
SOURCE_INDEX = 7
472+
DETECTION_CONTROL_STATUS_INDEX = 8
473+
DETECTION_PRESCRIPTION_STATUS_INDEX = 9
474+
DETECTION_VALIDATION_STATUS_INDEX = 10
475+
TILE_SETS_INDEX = 11
476+
CUSTOM_ZONES_INDEX = 12
477+
GEOMETRY_CENTER_INDEX = 13
474478

475479
for row in results:
476480
obj_id = row[ID_INDEX]
@@ -495,6 +499,9 @@ def process_rows(results):
495499
)
496500
)
497501

502+
# transform UUID to url
503+
row[UUID_INDEX] = f"https://{DOMAIN}/map?detectionObjectUuid={row[UUID_INDEX]}"
504+
498505
# format score
499506
row[SCORE_INDEX] = "{:.2f}".format(row[SCORE_INDEX] * 100)
500507

0 commit comments

Comments
 (0)