From 4eb3f822cbfbe4e970b9ad37cd1db226c3b75ae8 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 19 Mar 2025 15:25:59 +0100 Subject: 🐛 fix bad polygon agregation for town area MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index b5e6d705b..50abded4c 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2498,6 +2498,8 @@ class Area(HierarchicalType, DocumentItem, MainItem): name.append(town._generate_cached_label()) reference.append(town.numero_insee or slugify(town.name)) name = " / ".join(name) + if len(name) > 150: + name = name[:150] + " (...)" reference = f"area-{'/'.join(reference)}" area, created = cls.objects.get_or_create( reference=reference, @@ -2526,8 +2528,7 @@ class Area(HierarchicalType, DocumentItem, MainItem): source_content_type__app_label="ishtar_common", source_content_type__model="town", source_id__in=[t.pk for t in towns]) - q_poly = q_poly_towns.annotate(poly=Union("multi_polygon")) - poly = q_poly.all()[0].poly + poly = q_poly_towns.aggregate(poly=Union("multi_polygon"))["poly"] if not geo.multi_polygon or not geo.multi_polygon.equals_exact(poly, 0.001): origins, providers = [], [] for g in q_poly_towns: @@ -5847,6 +5848,8 @@ class Document( def document_changed(sender, **kwargs): + timestamp = int(datetime.datetime.now().timestamp()) + kwargs["timestamp"] = timestamp cached_label_changed(sender, **kwargs) if not settings.PDFTOPPM_BINARY or not kwargs.get("instance"): return -- cgit v1.2.3