diff options
Diffstat (limited to 'ishtar_common/models_imports.py')
| -rw-r--r-- | ishtar_common/models_imports.py | 14 | 
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" | 
