summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operation.html2
-rw-r--r--ishtar_common/models_common.py36
2 files changed, 37 insertions, 1 deletions
diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html
index b868185df..412d00473 100644
--- a/archaeological_operations/templates/ishtar/sheet_operation.html
+++ b/archaeological_operations/templates/ishtar/sheet_operation.html
@@ -179,7 +179,7 @@
{% if item.is_active %}
<i class="fa fa-check-circle text-success" aria-hidden="true"></i>
{% trans "Active file" %}
- {% else %}
+ {% elif is_external %}{% else %}
<i class="fa fa-stop-circle text-warning" aria-hidden="true"></i>
{% trans "Closed operation" %}
{% endif %}
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index feef29414..5e6e3af8f 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -2236,6 +2236,31 @@ class GeoVectorData(Imported, OwnPerms):
model.objects.filter(sub_q).values_list("id", flat=True)
)
+ SERIALIZE_EXCLUDE = []
+
+ def full_serialize(self, search_model, recursion=False):
+ dct = {}
+ fields = [
+ "id",
+ "buffer",
+ "buffer_type",
+ "name",
+ "origin",
+ "data_type",
+ "provider",
+ "comment",
+ "spatial_reference_system",
+ "source",
+ "estimated_error_x",
+ "estimated_error_y",
+ "estimated_error_z",
+ ]
+ for field_name in fields:
+ value = getattr(self, field_name)
+ dct[field_name] = str(value) if value else ""
+ dct["geojson"] = self.geojson
+ return dct
+
@classmethod
def get_query_owns(cls, ishtaruser):
q = None
@@ -4081,6 +4106,13 @@ class SerializeItem:
exclude = []
if search_model:
exclude = [sf.key for sf in search_model.sheet_filters.distinct().all()]
+
+ no_geodata = False
+ for prop in ("main_geodata", "geodata", "geodata_list"):
+ if prop in self.SERIALIZE_EXCLUDE or prop in exclude:
+ no_geodata = True
+ break
+
for field in self._meta.get_fields():
field_name = field.name
if field_name in self.SERIALIZE_EXCLUDE or field_name in exclude:
@@ -4097,6 +4129,8 @@ class SerializeItem:
and not recursion
):
# print(field.name, self.__class__, self)
+ if field_name == "main_geodata" and no_geodata:
+ continue
value = value.full_serialize(search_model, recursion=True)
elif field_name in self.SERIALIZATION_FILES:
try:
@@ -4108,6 +4142,8 @@ class SerializeItem:
else:
value = None
full_result[field_name] = value
+ if field_name == "main_geodata":
+ full_result["geodata_list"] = [value]
elif field.many_to_many:
values = getattr(self, field_name)
if values.count():