diff options
-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 |