summaryrefslogtreecommitdiff
path: root/ishtar_common/models_imports.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-06-18 16:51:11 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-06-18 16:51:11 +0200
commit9b3d54257b5024393284f2b1002acdb09615a1f1 (patch)
tree68d1e5941c5874e8bbd4c1aff0430fcbf542411d /ishtar_common/models_imports.py
parentee67a4dd81390da2841d6e7c7bd81a39d27e099a (diff)
downloadIshtar-9b3d54257b5024393284f2b1002acdb09615a1f1.tar.bz2
Ishtar-9b3d54257b5024393284f2b1002acdb09615a1f1.zip
✨ Media exporter: naming template
Diffstat (limited to 'ishtar_common/models_imports.py')
-rw-r--r--ishtar_common/models_imports.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py
index 23fb4f38e..e09ca2502 100644
--- a/ishtar_common/models_imports.py
+++ b/ishtar_common/models_imports.py
@@ -81,7 +81,8 @@ from ishtar_common.utils import (
reverse_coordinates,
update_data,
OwnPerms,
- SheetItem
+ SheetItem,
+ jinja_evaluation
)
from ishtar_common.data_importer import (
Importer,
@@ -3060,8 +3061,9 @@ class MediaExporter(models.Model):
naming = models.TextField(
_("Naming"), blank=True, null=False, default="",
help_text=_(
- "Can use jinja template logic to have conditionnal naming. If left empty, "
- "each media will be named with incremented numbers."
+ 'Jinja template. 3 variables are available: "document" for the document, '
+ '"item" for associated item and "item_type" for the item type (example: '
+ '"find"). If left empty, each media will be named with incremented numbers.'
)
)
@@ -3167,8 +3169,10 @@ class MediaExporter(models.Model):
base_name = media.path.split(os.path.sep)[-1]
ext = base_name.split(".")[-1]
if self.naming:
- # TODO: naming
- name = base_name
+ name = jinja_evaluation(
+ self.naming,
+ {"document": document, "item": item, "item_type": item_type}
+ ) + f".{ext}"
else:
if media_attr == "associated_file":
name = f"{item_type}_file"