summaryrefslogtreecommitdiff
path: root/ishtar_common/models_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r--ishtar_common/models_common.py24
1 files changed, 23 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()