mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 16:25:33 +01:00
Fix: Handling of Nones when using custom fields in filepath templating (#7933)
This commit is contained in:
parent
6292296876
commit
c2cfaaf8af
2 changed files with 15 additions and 4 deletions
|
|
@ -1322,7 +1322,7 @@ class TestFilenameGeneration(DirectoriesMixin, TestCase):
|
|||
extra_data={"select_options": ["ChoiceOne", "ChoiceTwo"]},
|
||||
)
|
||||
|
||||
CustomFieldInstance.objects.create(
|
||||
cfi1 = CustomFieldInstance.objects.create(
|
||||
document=doc_a,
|
||||
field=cf2,
|
||||
value_select=0,
|
||||
|
|
@ -1351,7 +1351,7 @@ class TestFilenameGeneration(DirectoriesMixin, TestCase):
|
|||
with override_settings(
|
||||
FILENAME_FORMAT="""
|
||||
{% if "Select Field" in custom_fields %}
|
||||
{{ title }}_{{ custom_fields | get_cf_value('Select Field') }}
|
||||
{{ title }}_{{ custom_fields | get_cf_value('Select Field', 'Default Value') }}
|
||||
{% else %}
|
||||
{{ title }}
|
||||
{% endif %}
|
||||
|
|
@ -1362,6 +1362,15 @@ class TestFilenameGeneration(DirectoriesMixin, TestCase):
|
|||
"Some Title_ChoiceOne.pdf",
|
||||
)
|
||||
|
||||
# Check for handling Nones well
|
||||
cfi1.value_select = None
|
||||
cfi1.save()
|
||||
|
||||
self.assertEqual(
|
||||
generate_filename(doc_a),
|
||||
"Some Title_Default Value.pdf",
|
||||
)
|
||||
|
||||
cf.name = "Invoice Number"
|
||||
cfi.value_int = 4567
|
||||
cfi.save()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue