summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
authorQuentin André <quentin.andre@imt-atlantique.net>2021-07-16 10:25:23 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-07-08 09:58:48 +0200
commit69662fc9a759b8c005a7c4bbfa755945ee3dfda1 (patch)
tree46ef9daf4115431ac8ac1cc33f8524a884d89b00 /archaeological_operations/models.py
parentdb7c86bda1e153c410faedb1b61b59acb353969d (diff)
downloadIshtar-69662fc9a759b8c005a7c4bbfa755945ee3dfda1.tar.bz2
Ishtar-69662fc9a759b8c005a7c4bbfa755945ee3dfda1.zip
format GeoJSON and getting properly related objects
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 578f90caa..c3c4f28f2 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -1607,23 +1607,20 @@ class Operation(
def get_geo_items(self, get_polygons, rounded=True):
dict = super(Operation, self).get_geo_items(get_polygons, rounded)
- associated_geo_items = {"associated context records": {}}
ContextRecord = apps.get_model(
"archaeological_context_records", "ContextRecord"
)
- for (
- cr
- ) in (
- self._get_associated_cached_labels()
- ): # malgré le nom, ce ne sont pas des labels ?
+ collection_context_records = []
+ for cr in self.context_record.distinct().all():
try:
- associated_geo_items["associated context records"][
- str(cr.label)
- ] = cr.get_geo_items(get_polygons, rounded)
+ geo_item = cr.get_geo_items(get_polygons, rounded)
+ collection_context_records.append(geo_item)
except ContextRecord.DoesNotExist:
- print("except")
pass
- dict["properties"] = associated_geo_items
+ dict["properties"]["context-records"] = {
+ "type": "FeatureCollection",
+ "features": collection_context_records,
+ }
return dict
def context_record_relations_q(self):