From 749e04350ecd47952f51913d6296de39d2a96e3a Mon Sep 17 00:00:00 2001 From: Quentin André Date: Mon, 26 Jul 2021 20:30:30 +0200 Subject: all in jquery and get_geo_items fixes --- archaeological_finds/tests.py | 18 ++--------------- ishtar_common/models_common.py | 10 +++++----- .../templates/ishtar/blocks/sheet_geo_items.html | 23 +++++++++++----------- .../templates/ishtar/blocks/sheet_simple_map.html | 14 ++++++------- 4 files changed, 25 insertions(+), 40 deletions(-) diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index c3b4a8c41..d6b2cc2ac 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -2879,17 +2879,6 @@ class GeomaticTest(FindInit, TestCase): }, "label": "OA2", } - dic_poly_pt_and_poly_pt_and_poly_f = copy.deepcopy(dic_poly_f) - dic_poly_pt_and_poly_pt_and_poly_f["properties"] = { - "context-records": { - "type": "FeatureCollection", - "features": [ - dic_poly_poly_and_pt_f, - dic_pt_poly_and_pt_f, - ], - }, - "label": "OA2", - } dic_poly_pt_and_poly_pt_and_poly_t = copy.deepcopy(dic_poly_t) dic_poly_pt_and_poly_pt_and_poly_t["properties"] = { "context-records": { @@ -2930,14 +2919,11 @@ class GeomaticTest(FindInit, TestCase): # ope is now a multipolygon ope_poly = Operation.objects.get(pk=ope.pk) ope_poly.multi_polygon = "SRID=4326;" + limit - ope_poly.point_source = None - ope_poly.point_2d = None - ope_poly.point = None ope_poly.save() ope_poly = Operation.objects.get(pk=ope_poly.pk) self.assertEqual( - dic_poly_pt_and_poly_pt_and_poly_f, ope_poly.get_geo_items(False) + dic_pt_pt_and_poly_pt_and_poly_f, ope_poly.get_geo_items(False) ) self.assertEqual( dic_poly_pt_and_poly_pt_and_poly_t, ope_poly.get_geo_items(True) @@ -2956,7 +2942,7 @@ class GeomaticTest(FindInit, TestCase): response = self.client.get(url_pts + "?operation_pk=" + str(ope_poly.pk)) self.assertEqual(response.status_code, 200) self.assertEqual( - dic_poly_pt_and_poly_pt_and_poly_f, json.loads(response.content) + dic_pt_pt_and_poly_pt_and_poly_f, json.loads(response.content) ) diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index cf994c8c0..08cfabdab 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2880,16 +2880,16 @@ class GeoItem(models.Model): dict["geometry"]["coordinates"] = list_coords else: dict["geometry"]["type"] = "Point" - if self.multi_polygon: - dict["geometry"]["coordinates"] = self.convert_coordinates( - self.multi_polygon.centroid, rounded - ) - else: + if self.point_2d: try: x, y = self.display_coordinates dict["geometry"]["coordinates"] = [x, y] except ValueError: dict["geometry"]["coordinates"] = [] + else: + dict["geometry"]["coordinates"] = self.convert_coordinates( + self.multi_polygon.centroid, rounded + ) return dict def convert_coordinates(self, point_2d, rounded): diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html index 9b485de15..36fbabfcf 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html @@ -24,18 +24,17 @@ -- cgit v1.2.3