summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py6
-rw-r--r--ishtar_common/models_common.py15
-rw-r--r--ishtar_common/templates/ishtar/blocks/api_document_list.html13
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_creation_section.html2
-rw-r--r--ishtar_common/templates/ishtar/blocks/window_image.html2
5 files changed, 30 insertions, 8 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index e72fd2a22..c1a53213f 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -3923,7 +3923,7 @@ class Document(
),
]
SERIALIZATION_FILES = ["image", "thumbnail", "associated_file"]
- SERIALIZE_PROPERTIES = ["external_id"]
+ SERIALIZE_PROPERTIES = ["external_id", "images_number"]
title = models.TextField(_("Title"), blank=True, default="")
associated_file = models.FileField(
@@ -4325,6 +4325,10 @@ class Document(
)
@property
+ def images_number(self):
+ return self.images.count()
+
+ @property
def main_image(self):
if self.images.count():
return self.images.all()[0]
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index bf1d10b5a..0d8eeac54 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -2566,6 +2566,10 @@ class DocumentItem:
)
@property
+ def images_number(self):
+ return self.images.count()
+
+ @property
def images_without_main_image(self):
if not hasattr(self, "main_image") or not hasattr(self, "documents"):
return self.images
@@ -3251,7 +3255,8 @@ class ShortMenuItem:
class SerializeItem:
SERIALIZE_EXCLUDE = ["search_vector"]
- SERIALIZE_PROPERTIES = ["external_id", "multi_polygon_geojson", "point_2d_geojson"]
+ SERIALIZE_PROPERTIES = ["external_id", "multi_polygon_geojson", "point_2d_geojson",
+ "images_number", "json_sections"]
SERIALIZE_CALL = {}
SERIALIZE_DATES = []
SERIALIZATION_FILES = []
@@ -3279,7 +3284,7 @@ class SerializeItem:
and hasattr(value, "full_serialize")
and not recursion
):
- # print(field.name)
+ #print(field.name, self.__class__, self)
value = value.full_serialize(recursion=True)
elif field_name in self.SERIALIZATION_FILES:
try:
@@ -3300,7 +3305,7 @@ class SerializeItem:
and hasattr(first_value, "full_serialize")
and not recursion
):
- # print(field.name)
+ #print(field.name, self.__class__, self)
values = [
v.full_serialize(recursion=True) for v in values.all()
]
@@ -3309,7 +3314,7 @@ class SerializeItem:
values = []
for v in values:
try:
- values.append({"url": value.url})
+ values.append({"url": v.url})
except ValueError:
pass
else:
@@ -3330,8 +3335,6 @@ class SerializeItem:
result = json.loads(serialize("json", [self], fields=serialize_fields))
full_result.update(result[0]["fields"])
- if "main_image" in full_result:
- print(full_result["main_image"])
for prop in self.SERIALIZE_PROPERTIES:
if hasattr(self, prop) and prop not in full_result:
full_result[prop] = getattr(self, prop)
diff --git a/ishtar_common/templates/ishtar/blocks/api_document_list.html b/ishtar_common/templates/ishtar/blocks/api_document_list.html
new file mode 100644
index 000000000..251885a19
--- /dev/null
+++ b/ishtar_common/templates/ishtar/blocks/api_document_list.html
@@ -0,0 +1,13 @@
+<table class='table table-striped datatables'
+ id="{{window_id}}-docs-table">
+ {% for values in item.documents_list %}{% if not forloop.counter0 %}
+ <thead>
+ {% for value in values %}<th class="text-center">{{value}}</th>{% endfor %}
+ </thead>
+ {% else %}
+ <tr>
+ {% for value in values %}<td>{{value}}</td>{% endfor %}
+ </tr>
+ {% endif %}
+ {% endfor %}
+</table>
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_creation_section.html b/ishtar_common/templates/ishtar/blocks/sheet_creation_section.html
index a848dad5d..46856cad0 100644
--- a/ishtar_common/templates/ishtar/blocks/sheet_creation_section.html
+++ b/ishtar_common/templates/ishtar/blocks/sheet_creation_section.html
@@ -1,4 +1,5 @@
{% load i18n link_to_window %}
+{% if not is_external %}
{% if item.history_creator.ishtaruser.person %}
<div class="col-12 col-md-6 col-lg-3 flex-wrap text-muted"
title="{% trans 'Creation' context 'Sheet' %}">
@@ -17,3 +18,4 @@
<small>{% firstof item.history_date|date:"DATETIME_FORMAT" item.history.all.0.history_date|date:"DATETIME_FORMAT" %}</small>
</div>
{% endif %}
+{% endif %}
diff --git a/ishtar_common/templates/ishtar/blocks/window_image.html b/ishtar_common/templates/ishtar/blocks/window_image.html
index 8f0c0dbed..409ad25fa 100644
--- a/ishtar_common/templates/ishtar/blocks/window_image.html
+++ b/ishtar_common/templates/ishtar/blocks/window_image.html
@@ -1,4 +1,4 @@
-{% load i18n link_to_window %}{% if item.images.count %}
+{% load i18n link_to_window %}{% if item.images_number %}
{% if output == "ODT" or output == "PDF"%}
{% include "ishtar/blocks/window_image_odt.html" %}
{% else %}