feat: add ITS asset models and views for location and bollard management

This commit is contained in:
Karl Determe 2026-10-09 15:04:41 +02:00
parent cd3f3999cb
commit da9e5c1cb8
2 changed files with 9 additions and 1 deletions

View file

@ -158,6 +158,10 @@ class ITSBollardSystem(AbstractGeoAsset):
def plots_count(self): def plots_count(self):
return self.plots.count() return self.plots.count()
@property
def name(self):
return self.get_name()
BOLLARD_TYPE_CHOICES = ( BOLLARD_TYPE_CHOICES = (
('automatic', _('Automatique / Escamotable')), ('automatic', _('Automatique / Escamotable')),
@ -178,6 +182,10 @@ class ITSBollardPlot(AbstractGeoAsset):
location = models.ForeignKey(ITSLocation, related_name="bollard_plots", on_delete=models.SET_NULL, null=True, blank=True, verbose_name=_("Localisation ITS")) location = models.ForeignKey(ITSLocation, related_name="bollard_plots", on_delete=models.SET_NULL, null=True, blank=True, verbose_name=_("Localisation ITS"))
extra_data = models.JSONField(default=dict, blank=True, verbose_name=_("Métadonnées techniques")) extra_data = models.JSONField(default=dict, blank=True, verbose_name=_("Métadonnées techniques"))
@property
def name(self):
return self.get_name()
def clean(self): def clean(self):
super().clean() super().clean()
if not self.location_id and self.system and self.system.location_id: if not self.location_id and self.system and self.system.location_id:

View file

@ -354,7 +354,7 @@ def its_assets_geojson(request):
props["bollard_type"] = obj.get_bollard_type_display() if hasattr(obj, 'get_bollard_type_display') else obj.bollard_type props["bollard_type"] = obj.get_bollard_type_display() if hasattr(obj, 'get_bollard_type_display') else obj.bollard_type
if getattr(obj, 'system', None): if getattr(obj, 'system', None):
props["system_code"] = obj.system.code props["system_code"] = obj.system.code
props["system_name"] = obj.system.name props["system_name"] = obj.system.get_name() if hasattr(obj.system, 'get_name') else (obj.system.name_fr or obj.system.name_nl or obj.system.code)
return { return {
"type": "Feature", "type": "Feature",
"id": obj.id, "id": obj.id,