diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-03-19 15:25:59 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-03-19 15:27:11 +0100 |
commit | 4eb3f822cbfbe4e970b9ad37cd1db226c3b75ae8 (patch) | |
tree | 44d88cc538e0eda3a16487dd6b199688f45df8a2 | |
parent | b0c2ded8e95dcf61b36685fec4b40d9bcf82bef0 (diff) | |
download | Ishtar-4eb3f822cbfbe4e970b9ad37cd1db226c3b75ae8.tar.bz2 Ishtar-4eb3f822cbfbe4e970b9ad37cd1db226c3b75ae8.zip |
🐛 fix bad polygon agregation for town area
-rw-r--r-- | ishtar_common/models.py | 7 |
1 files 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 |