mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Get rid of fill_list and rather use defaultdict
This commit is contained in:
parent
12c7b0d5f5
commit
7f1e1052fe
@ -328,25 +328,15 @@ class Document(models.Model):
|
|||||||
if settings.PAPERLESS_FILENAME_FORMAT is not None:
|
if settings.PAPERLESS_FILENAME_FORMAT is not None:
|
||||||
tag = defaultdict(lambda: slugify(None),
|
tag = defaultdict(lambda: slugify(None),
|
||||||
self.many_to_dictionary(self.tags))
|
self.many_to_dictionary(self.tags))
|
||||||
list_length = 10
|
tags = defaultdict(lambda: slugify(None),
|
||||||
tags = self.many_to_list(self.tags)
|
enumerate(self.many_to_list(self.tags)))
|
||||||
while True:
|
path = settings.PAPERLESS_FILENAME_FORMAT.format(
|
||||||
tags = Document.fill_list(tags, list_length, None)
|
correspondent=slugify(self.correspondent),
|
||||||
try:
|
title=slugify(self.title),
|
||||||
path = settings.PAPERLESS_FILENAME_FORMAT.format(
|
created=slugify(self.created),
|
||||||
correspondent=slugify(self.correspondent),
|
added=slugify(self.added),
|
||||||
title=slugify(self.title),
|
tag=tag,
|
||||||
created=slugify(self.created),
|
tags=tags)
|
||||||
added=slugify(self.added),
|
|
||||||
tag=tag,
|
|
||||||
tags=tags)
|
|
||||||
break
|
|
||||||
except IndexError:
|
|
||||||
list_length *= 10
|
|
||||||
|
|
||||||
if list_length > 1000:
|
|
||||||
path = ""
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
path = ""
|
path = ""
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ class TestDate(TestCase):
|
|||||||
# Ensure that filename is properly generated
|
# Ensure that filename is properly generated
|
||||||
tmp = document.source_filename
|
tmp = document.source_filename
|
||||||
self.assertEqual(document.generate_source_filename(),
|
self.assertEqual(document.generate_source_filename(),
|
||||||
"0000001.pdf")
|
"none-0000001.pdf")
|
||||||
document.create_source_directory()
|
document.create_source_directory()
|
||||||
Path(document.source_path).touch()
|
Path(document.source_path).touch()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user