Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file candidates include locality #2013

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion indigo_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,53 @@ def filename_candidates(document, prefix='', suffix=''):
This takes into account the country, type, subtype and language of the document,
providing a number of opportunities to adjust the rendering logic.

The following templates are looked for, in order:
The following templates are looked for, in order. Note that place includes locality, and is only used
if place != country (e.g. za-cpt vs za)

* doctype-subtype-language-place
* doctype-subtype-language-country
* doctype-subtype-language
* doctype-subtype-place
* doctype-subtype-country
* doctype-subtype
* doctype-language-place
* doctype-language-country
* doctype-place
* doctype-country
* doctype-language
* doctype
* place
* country
* akn
"""
uri = document.expression_uri
doctype = uri.doctype
language = uri.language
country = uri.country
place = uri.place
subtype = uri.subtype

options = []
if subtype:
if country != place:
options.append('-'.join([doctype, subtype, language, place]))
options.append('-'.join([doctype, subtype, language, country]))
options.append('-'.join([doctype, subtype, language]))
if country != place:
options.append('-'.join([doctype, subtype, place]))
options.append('-'.join([doctype, subtype, country]))
options.append('-'.join([doctype, subtype]))

if country != place:
options.append('-'.join([doctype, language, place]))
options.append('-'.join([doctype, language, country]))
if country != place:
options.append('-'.join([doctype, place]))
options.append('-'.join([doctype, country]))
options.append('-'.join([doctype, language]))
options.append(doctype)
if country != place:
options.append(place)
options.append(country)
options.append('akn')

Expand Down
Loading