fix(home): safe status choices lookup and thematic localized fields in activity_geojson
This commit is contained in:
parent
1b93f3ae88
commit
f534758f91
1 changed files with 10 additions and 10 deletions
|
|
@ -1243,16 +1243,16 @@ def activity_geojson(request):
|
||||||
features = []
|
features = []
|
||||||
|
|
||||||
# URLs de base précalculées pour éviter d'appeler reverse() des milliers de fois
|
# URLs de base précalculées pour éviter d'appeler reverse() des milliers de fois
|
||||||
interv_base_url = reverse("interventions:intervention_detail", args=[0])[:-2]
|
interv_base_url = reverse("interventions:intervention_detail", args=[0]).rstrip('0/')
|
||||||
obs_base_url = reverse("observations:observation_detail", args=[0])[:-2]
|
obs_base_url = reverse("observations:observation_detail", args=[0]).rstrip('0/')
|
||||||
ctrl_base_url = reverse("controls:controls_detail", args=[0])[:-2]
|
ctrl_base_url = reverse("controls:controls_detail", args=[0]).rstrip('0/')
|
||||||
insp_list_url = reverse("inspections:inspections_list")
|
insp_list_url = reverse("inspections:inspections_list")
|
||||||
|
|
||||||
# Dictionnaires de libellés de statut pour accès O(1)
|
# Dictionnaires de libellés de statut pour accès O(1)
|
||||||
interv_status_dict = dict(Intervention.STATUS_CHOICES)
|
interv_status_dict = dict(Intervention._meta.get_field('status').choices or [])
|
||||||
obs_status_dict = dict(Observation.STATUS_CHOICES)
|
obs_status_dict = dict(Observation._meta.get_field('status').choices or [])
|
||||||
insp_status_dict = dict(getattr(Inspection, 'STATUS_CHOICES', []))
|
insp_status_dict = dict(Inspection._meta.get_field('status').choices or [])
|
||||||
ctrl_status_dict = dict(getattr(Control, 'STATUS_CHOICES', []))
|
ctrl_status_dict = dict(Control._meta.get_field('status').choices or [])
|
||||||
|
|
||||||
# 1. Interventions du contrat (projection EPSG:4326 au niveau PostGIS)
|
# 1. Interventions du contrat (projection EPSG:4326 au niveau PostGIS)
|
||||||
intervs = (
|
intervs = (
|
||||||
|
|
@ -1265,7 +1265,7 @@ def activity_geojson(request):
|
||||||
.annotate(geom_4326=Transform(Centroid('geom'), 4326))
|
.annotate(geom_4326=Transform(Centroid('geom'), 4326))
|
||||||
.only(
|
.only(
|
||||||
'id', 'code', 'title', 'description', 'status', 'address', 'creation_time',
|
'id', 'code', 'title', 'description', 'status', 'address', 'creation_time',
|
||||||
'thematic__id', 'thematic__name', 'thematic__code'
|
'thematic__id', 'thematic__name_fr', 'thematic__name_nl', 'thematic__code'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1308,7 +1308,7 @@ def activity_geojson(request):
|
||||||
.annotate(geom_4326=Transform(Centroid('geom'), 4326))
|
.annotate(geom_4326=Transform(Centroid('geom'), 4326))
|
||||||
.only(
|
.only(
|
||||||
'id', 'code', 'description', 'status', 'address', 'created_at',
|
'id', 'code', 'description', 'status', 'address', 'created_at',
|
||||||
'thematic__id', 'thematic__name', 'thematic__code'
|
'thematic__id', 'thematic__name_fr', 'thematic__name_nl', 'thematic__code'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1352,7 +1352,7 @@ def activity_geojson(request):
|
||||||
.only(
|
.only(
|
||||||
'id', 'nature', 'notes', 'status', 'created_at',
|
'id', 'nature', 'notes', 'status', 'created_at',
|
||||||
'mission_intervention__id', 'mission_intervention__address',
|
'mission_intervention__id', 'mission_intervention__address',
|
||||||
'mission_intervention__thematic__id', 'mission_intervention__thematic__name', 'mission_intervention__thematic__code'
|
'mission_intervention__thematic__id', 'mission_intervention__thematic__name_fr', 'mission_intervention__thematic__name_nl', 'mission_intervention__thematic__code'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue