diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-05-05 18:45:33 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:21:00 +0100 |
commit | 0f5d1297503a97e865ce211b2a0c801b21cfd613 (patch) | |
tree | bc849de6718bea64126c2d25fc36973a0599fb1c /ishtar_common | |
parent | 810d6074789e3e6b11854f676314972a6952b486 (diff) | |
download | Ishtar-0f5d1297503a97e865ce211b2a0c801b21cfd613.tar.bz2 Ishtar-0f5d1297503a97e865ce211b2a0c801b21cfd613.zip |
Geodata: display geodata list on sheet
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/models_common.py | 24 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_geographic.html | 27 |
2 files changed, 50 insertions, 1 deletions
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() @@ -2356,6 +2374,10 @@ class GeoVectorData(Imported): 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: geo = GEOJSON_POINT_TPL.copy() 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 %} +<table id='{{window_id}}-geographic-data' class="table table-striped"> + <tr> + {% if permission_change_geo %}<th> </th>{% endif %} + <th>{% trans "Main" %}</th> + <th>{% trans "Data type" %}</th> + <th>{% trans "Source" %}</th> + <th>{% trans "Geometry" %}</th> + <th>{% trans "Name" %}</th> + <th>{% trans "Origin" %}</th> + <th>{% trans "Provider" %}</th> + <th>{% trans "Comment" %}</th> + </tr> +{% for geo in geo_item.geodata.all %} + <tr> + {% if permission_change_geo %}<td><a href="#"><i class="fa fa-pencil"></i></a></td>{% endif %} + <td>{% if geo.id == geo_item.main_geodata_id %}<i class="fa fa-check-circle text-success" aria-hidden="true"></i>{% else %}–{% endif %}</td> + <td>{% if geo.data_type %}{{ geo.data_type }}{% else %}-{% endif %}</td> + <td>{{ geo.source_label }}</td> + <td>{{ geo.geometry_type_label }}</td> + <td>{{ geo.name }}</td> + <td>{% if geo.origin %}{{ geo.origin }}{% else %}-{% endif %}</td> + <td>{% if geo.provider %}{{ geo.provider }}{% else %}-{% endif %}</td> + <td>{% if geo.comment %}{{ geo.comment }}{% else %}-{% endif %}</td> + </tr> +{% endfor %} +</table> |