From 0f5d1297503a97e865ce211b2a0c801b21cfd613 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 5 May 2022 18:45:33 +0200 Subject: Geodata: display geodata list on sheet --- ishtar_common/models_common.py | 24 ++++++++++++++++++- .../templates/ishtar/blocks/sheet_geographic.html | 27 ++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 ishtar_common/templates/ishtar/blocks/sheet_geographic.html (limited to 'ishtar_common') diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 12f8b0507..07aaa18ea 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2079,8 +2079,16 @@ GEOJSON_POINT_TPL = { } +GEOMETRY_TYPE_LBL = { + "POINT": _("Point"), + "MULTILINE": _("Line(s)"), + "MULTIPOINTS": _("Points"), + "MULTIPOLYGON": _("Polygon(s)"), +} + + class GeoVectorData(Imported): - name = models.TextField(_("Name"), default=_("Default")) + name = models.TextField(_("Name"), default="-") source_content_type = models.ForeignKey( ContentType, related_name="content_type_geovectordata", on_delete=models.CASCADE ) @@ -2145,6 +2153,12 @@ class GeoVectorData(Imported): verbose_name = _("Geographic - Vector data") verbose_name_plural = _("Geographic - Vector data") unique_together = ("source_content_type", "source_id", "import_key") + permissions = ( + ("view_own_geovectordata", "Can view own Geographic - Vector data"), + ("add_own_geovectordata", "Can add own Geographic - Vector data"), + ("change_own_geovectordata", "Can change own Geographic - Vector data"), + ("delete_own_geovectordata", "Can delete own Geographic - Vector data"), + ) def __str__(self): name = self.name @@ -2152,6 +2166,10 @@ class GeoVectorData(Imported): name += f" ({str(self.data_type).lower()})" return name + @property + def source_label(self): + return str(self.source) + def display_coordinates(self, rounded=5, dim=2, srid=4326, cache=True): if not srid: profile = get_current_profile() @@ -2355,6 +2373,10 @@ class GeoVectorData(Imported): return "MULTIPOLYGON" return "" + @property + def geometry_type_label(self): + return GEOMETRY_TYPE_LBL.get(self.geometry_type, "") + @property def geojson(self): if self.x or self.y or self.z: diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html new file mode 100644 index 000000000..c5a413cc6 --- /dev/null +++ b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html @@ -0,0 +1,27 @@ +{% load i18n window_field %} + + + {% if permission_change_geo %}{% endif %} + + + + + + + + + +{% for geo in geo_item.geodata.all %} + + {% if permission_change_geo %}{% endif %} + + + + + + + + + +{% endfor %} +
 {% trans "Main" %}{% trans "Data type" %}{% trans "Source" %}{% trans "Geometry" %}{% trans "Name" %}{% trans "Origin" %}{% trans "Provider" %}{% trans "Comment" %}
{% if geo.id == geo_item.main_geodata_id %}{% else %}–{% endif %}{% if geo.data_type %}{{ geo.data_type }}{% else %}-{% endif %}{{ geo.source_label }}{{ geo.geometry_type_label }}{{ geo.name }}{% if geo.origin %}{{ geo.origin }}{% else %}-{% endif %}{% if geo.provider %}{{ geo.provider }}{% else %}-{% endif %}{% if geo.comment %}{{ geo.comment }}{% else %}-{% endif %}
-- cgit v1.2.3