Add {series_sort} to the download template

It gives the series with a leading article at the end, as Calibre's default does for {series}.
This commit is contained in:
tim
2026-10-03 08:09:41 +02:00
parent dcdd8e4ac7
commit ece59c2558
5 changed files with 19 additions and 4 deletions
+2
View File
@@ -164,6 +164,8 @@ def test_download_template_names_the_file(client, story):
# The default moves the article to the end, as Calibre's default does.
client.put("/api/settings", json={"download_template": ""}, headers=H)
assert 'filename="Book, The - Ann Writer.epub"' in download_name(client, sid)
client.put("/api/settings", json={"download_template": "{series_sort} - {title} - {id}"}, headers=H)
assert f'filename="Saga, The - The Book - {sid}.epub"' in download_name(client, sid)
# The ID is that of the CWA book, when the story has one.
o.store.update_story(sid, calibre_id=77, pinned={"title": "Caf\u00e9", "series": ["", None]})
client.put("/api/settings", json={"download_template": "{series:|| - }{title} - {id}"}, headers=H)
+5
View File
@@ -55,6 +55,11 @@ def test_reference_cases_for_a_missing_series_and_for_alphabetic_order():
assert expand("{series}", "strictly_alphabetic") == "The Saga"
def test_series_sort_is_a_bindery_field():
assert expand("{series_sort}") == expand("{series_sort}", "strictly_alphabetic") == "Saga, The"
assert ft.expand("x{series_sort}x", ft.prepare(NO_SERIES, 42)) == "xx"
@pytest.mark.parametrize(
"template,expected",
[