Skip to content

Commit

Permalink
data model: fix server error during the provisionActivity formatting.
Browse files Browse the repository at this point in the history
* Fixes server error for documents search REST API with two data statement in provisionActivity.
* Updates dependencies.

Co-Authored-by: Johnny Mariéthoz <[email protected]>
  • Loading branch information
jma committed Jun 5, 2024
1 parent 4b8d09c commit 889103c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 6 additions & 3 deletions sonar/modules/documents/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def publication_statement_text(provision_activity):
if 'statement' not in provision_activity:
return format_date(provision_activity['startDate'])

punctuation = {'bf:Place': ' ; ', 'bf:Agent': ', '}
punctuation = {
'bf:Place': ' ; ',
'bf:Agent': ', ',
'Date': ', '
}

statement_with_language = {'default': ''}
statement_type = None
Expand All @@ -49,8 +53,7 @@ def publication_statement_text(provision_activity):
for label in labels:
language = label.get('language', 'default')

if not statement_with_language.get(language):
statement_with_language[language] = ''
statement_with_language.setdefault(language, '')

if statement_with_language[language]:
if statement_type == statement['type']:
Expand Down
8 changes: 7 additions & 1 deletion tests/ui/documents/test_documents_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ def test_publication_statement_text():
"value": "1798-1799"
}],
"type": "Date"
},
{
"label": [{
"value": "1900-1999"
}],
"type": "Date"
}]
}) == {
'default': 'Lausanne : Bulletin officiel du Directoire, 1798-1799'
'default': 'Lausanne : Bulletin officiel du Directoire, 1798-1799, 1900-1999'
}

# Without statement
Expand Down

0 comments on commit 889103c

Please sign in to comment.