prevent usage of {tags} directly.

This commit is contained in:
jonaswinkler
2020-12-14 03:01:50 +01:00
parent 972c8baae9
commit b012086dd8
2 changed files with 17 additions and 2 deletions

View File

@@ -8,6 +8,12 @@ from django.conf import settings
from django.template.defaultfilters import slugify
class defaultdictNoStr(defaultdict):
def __str__(self):
raise ValueError("Don't use {tags} directly.")
def create_source_path_directory(source_path):
os.makedirs(os.path.dirname(source_path), exist_ok=True)
@@ -90,8 +96,8 @@ def generate_filename(doc, counter=0):
try:
if settings.PAPERLESS_FILENAME_FORMAT is not None:
tags = defaultdict(lambda: slugify(None),
many_to_dictionary(doc.tags))
tags = defaultdictNoStr(lambda: slugify(None),
many_to_dictionary(doc.tags))
if doc.correspondent:
correspondent = pathvalidate.sanitize_filename(