diff options
-rw-r--r-- | archaeological_finds/tests.py | 18 | ||||
-rw-r--r-- | ishtar_common/models_common.py | 10 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_geo_items.html | 23 | ||||
-rw-r--r-- | ishtar_common/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 4691de69c..7ee508a00 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2871,16 +2871,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 @@ </dl> <script> var hide_get_polygons = function() { - const disp = $("#display-geo-items")[0]; - const get_poly = $("#get-polygons")[0]; - const label = $("#label-get-polygons")[0]; - get_poly.hidden = true; - label.hidden = true; - disp.addEventListener('change', (event) => { - if (event.target.value === "") { - get_poly.hidden = true; - label.hidden = true; - get_poly.value = ""; - } else { get_poly.hidden = false; - label.hidden = false;} + const disp = $("#display-geo-items"); + const get_poly = $("#get-polygons"); + const label = $("#label-get-polygons"); + get_poly.hide(); + label.hide(); + disp.change( function () { + if (disp.val() === "") { + get_poly.hide(); + label.hide(); + } else { get_poly.show(); + label.show();} }) } hide_get_polygons(); diff --git a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html index 2c9d49be2..b4e669a70 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html @@ -38,20 +38,20 @@ var display_geo_items = function(disp, get_polygons) { } var geo_items_displayed_once = false; -var disp = $("#display-geo-items")[0]; -var get_polygons = $("#get-polygons")[0]; -disp.addEventListener('change', (event) => { +var disp = $("#display-geo-items"); +var get_polygons = $("#get-polygons"); +disp.change( function () { if (geo_items_displayed_once) { disp_map(); } - if (disp.value !== "") { - display_geo_items(disp.value, get_polygons.value); + if (disp.val() !== "") { + display_geo_items(disp.val(), get_polygons.val()); geo_items_displayed_once = true; } }) -get_polygons.addEventListener('change', (event) => { +get_polygons.change( function () { disp_map(); - display_geo_items(disp.value, get_polygons.value); + display_geo_items(disp.val(), get_polygons.val()); }) {% endif %} </script> |