summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/models.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 12d203a7c..1209a11cb 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -25,6 +25,7 @@ from django.conf import settings
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
from django.contrib.postgres.indexes import GinIndex
+from django.contrib.sites.models import Site
from django.db import connection
from django.db.models import Q
from django.db.models.signals import post_delete, post_save, m2m_changed
@@ -66,7 +67,7 @@ from ishtar_common.models import (
QuickAction,
RelationsViews,
)
-from ishtar_common.models_common import HistoricalRecords, SerializeItem
+from ishtar_common.models_common import GeoVectorData, HistoricalRecords, SerializeItem
from archaeological_operations.models import (
Operation,
Period,
@@ -961,17 +962,24 @@ class ContextRecord(
def get_geo_items(self, rounded=True):
dct = super(ContextRecord, self).get_geo_items(rounded=rounded)
- BaseFind = apps.get_model("archaeological_finds", "BaseFind")
- collection_base_finds = []
- for bf in self.base_finds.distinct().all():
- try:
- geo_item = bf.get_geo_items(rounded=rounded)
- collection_base_finds.append(geo_item)
- except BaseFind.DoesNotExist:
- pass
- dct["properties"]["base-finds"] = {
+ site = Site.objects.get_current()
+ scheme = "https" if settings.ISHTAR_SECURE else "http"
+ base_url = scheme + "://" + site.domain
+
+ profile = get_current_profile()
+ precision = profile.point_precision
+
+ current_geodata = list(self.geodata.values_list("id", flat=True))
+
+ q = self.base_finds.filter(main_geodata__isnull=False)
+ url = base_url + "/show-basefind/{}/"
+ collection_finds = GeoVectorData._get_geo_item_list(
+ q, current_geodata, url, precision, rounded
+ )
+
+ dct["finds"] = {
"type": "FeatureCollection",
- "features": collection_base_finds,
+ "features": collection_finds,
}
return dct