Skip to content

Commit

Permalink
document: fix processing of title field
Browse files Browse the repository at this point in the history
* Closes rero#1745.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Mar 11, 2021
1 parent fe5ed8c commit 89d4aca
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rero_ils/modules/documents/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ def title_format_text(title, with_subtitle=True):
for main_title in main_titles:
language = main_title.get('language', 'default')
value = main_title.get('value', '')
main_title_output[language] = value
if language not in main_title_output:
main_title_output[language] = []
main_title_output[language].append(value)

# build subtitle string per language
subtitle_output = {}
Expand All @@ -404,7 +406,9 @@ def title_format_text(title, with_subtitle=True):
for subtitle in subtitles:
language = subtitle.get('language', 'default')
value = subtitle.get('value', '')
subtitle_output[language] = value
if language not in subtitle_output:
subtitle_output[language] = []
subtitle_output[language].append(value)

# build part strings per language
parts = title.get('part', [])
Expand All @@ -428,9 +432,9 @@ def title_format_text(title, with_subtitle=True):
# if a vernacular title exists it will be place on top of the title list
title_text = []
for key, value in main_title_output.items():
value = main_title_output.get(key)
value = '. '.join(main_title_output.get(key))
if subtitle_output and with_subtitle and key in subtitle_output:
value = ' : '.join((value, subtitle_output.get(key)))
value = ' : '.join((value, ' : '.join(subtitle_output.get(key))))
if part_output and key in part_output and part_output.get(key):
value = '. '.join((value, part_output.get(key)))
if display_alternate_graphic_first(key):
Expand Down

0 comments on commit 89d4aca

Please sign in to comment.