From 5db00ec09c62f08e4026dec36de7c4d981b37eae Mon Sep 17 00:00:00 2001 From: kdeterme Date: Mon, 27 Jul 2026 08:29:13 +0200 Subject: [PATCH] feat: add Localisation, Documents and Interventions tabs to public building detail view --- .../buildings/publicbuilding_detail.html | 238 +++++++++++++++++- streetup/assets/views/buildings.py | 33 ++- 2 files changed, 262 insertions(+), 9 deletions(-) diff --git a/streetup/assets/templates/assets/buildings/publicbuilding_detail.html b/streetup/assets/templates/assets/buildings/publicbuilding_detail.html index 0246b14..7c80dcd 100644 --- a/streetup/assets/templates/assets/buildings/publicbuilding_detail.html +++ b/streetup/assets/templates/assets/buildings/publicbuilding_detail.html @@ -1,8 +1,14 @@ {% extends "base.html" %} -{% load static i18n %} +{% load static i18n documents_tags %} {% block title %}{{ building.code }} - {{ building.get_name }} | StreetUp{% endblock %} +{% block extra_head %} + + + +{% endblock %} + {% block content %}
@@ -61,19 +67,41 @@
- + +
@@ -130,7 +158,50 @@
- + +
+
+
+
+
+ {% translate "Emprise cartographique" %} + {% if center_lat and center_lon %} + + Street View + {% translate "Google Street View" %} + + {% endif %} +
+
+
+
+
+
+
+
+
{% translate "Adresse & Coordonnées" %}
+
+

+ {% translate "Adresse complète" %} : + {{ building.address|default:_("Non renseignée") }} +

+ {% if center_lat and center_lon %} +
+
{% translate "Coordonnées WGS84 (Lat, Lon)" %} :
+
{{ center_lat|floatformat:6 }}, {{ center_lon|floatformat:6 }}
+
+ {% endif %} +
+ {% translate "Emprise vectorielle (MultiPolygone SRID 3812)." %} +
+
+
+
+
+
+ +
@@ -157,7 +228,7 @@
- +
@@ -188,6 +259,159 @@
+ + +
+
+
+
{% translate "Documents associés" %}
+ + {% translate "Ajouter un document" %} + +
+
+
+ {% for doc in documents %} +
+
+
+ {% if doc.document.file %} + +
{{ doc.document.file.name }}
+ + {% translate "Télécharger" %} + + {% else %} + + {% translate "Fichier indisponible" %} + {% endif %} +
+
+
+ {% empty %} +
+ + {% translate "Aucun document associé à ce bâtiment public." %} +
+ {% endfor %} +
+
+
+
+ + +
+
+
+
{% translate "Interventions & Maintenance" %}
+ + {% translate "Nouvelle intervention" %} + +
+
+ + + + + + + + + + + + {% for interv in interventions %} + + + + + + + + {% empty %} + + + + {% endfor %} + +
{% translate "Code" %}{% translate "Titre / Objet" %}{% translate "Date de début" %}{% translate "Statut" %}
+ + + + {{ interv.code }}{{ interv.title }}{{ interv.begin_time|date:"d/m/Y H:i"|default:"-" }}{{ interv.get_status_display }}
+ + {% translate "Aucune intervention enregistrée pour ce bâtiment." %} +
+
+
+
+
{% endblock %} + +{% block script %} + +{% endblock script %} diff --git a/streetup/assets/views/buildings.py b/streetup/assets/views/buildings.py index 140b792..234d77f 100644 --- a/streetup/assets/views/buildings.py +++ b/streetup/assets/views/buildings.py @@ -182,13 +182,37 @@ def buildings_index(request): @login_required def building_detail(request, pk): """ - Vue détaillée d'un Bâtiment Public avec ses niveaux, pièces et équipements. + Vue détaillée d'un Bâtiment Public avec ses niveaux, pièces, équipements, documents, interventions et cartographie. """ + from django.contrib.contenttypes.models import ContentType + from interventions.models import Intervention + from interventions.permissions import filter_viewable_interventions_for_user + building = get_object_or_404(PublicBuilding, pk=pk) levels = building.levels.all().prefetch_related('rooms') rooms = building.rooms.all() equipments = building.equipments.all() - documents = building.documents.select_related('document').all() + documents = building.documents.all() + + content_type = ContentType.objects.get_for_model(PublicBuilding) + + # Récupération des interventions associées au bâtiment + interventions_qs = Intervention.objects.filter( + interventionasset__object_id=building.id, + interventionasset__content_type=content_type + ).distinct().order_by('-creation_time') + + interventions = filter_viewable_interventions_for_user(request.user, interventions_qs) + + # GeoJSON pour la carte de localisation + building_geojson = None + center_lon, center_lat = None, None + if building.geom: + geom_4326 = building.geom.clone() + geom_4326.transform(4326) + building_geojson = json.loads(geom_4326.json) + centroid = geom_4326.centroid + center_lon, center_lat = centroid.x, centroid.y context = { 'building': building, @@ -196,5 +220,10 @@ def building_detail(request, pk): 'rooms': rooms, 'equipments': equipments, 'documents': documents, + 'interventions': interventions, + 'content_type': content_type, + 'building_geojson_json': json.dumps(building_geojson) if building_geojson else 'null', + 'center_lon': center_lon, + 'center_lat': center_lat, } return render(request, 'assets/buildings/publicbuilding_detail.html', context)