Skip to content

Commit

Permalink
fix formatter for places with missing wikidata id (#465)
Browse files Browse the repository at this point in the history
SDNTB-852
  • Loading branch information
petrjasek authored Oct 23, 2023
1 parent 230bd6e commit 147fa50
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/ntb/publish/ntb_nitf.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,12 @@ def _format_place(self, article, docdata):
for attrib, keys in mapping:
for key in keys:
if data.get(key):
if not data.get("wikidata") and key == "altids":
if not data.get("wikidata") and key == "altids" and data.get("altids").get("wikidata"):
evloc.attrib[attrib] = data.get("altids", {}).get(
"wikidata"
)
else:
break
elif isinstance(data.get(key), str):
evloc.attrib[attrib] = data[key]
break

Expand Down
15 changes: 15 additions & 0 deletions server/ntb/tests/publish/ntb_ninjs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ class Ninjs2FormatterTest(TestCase):
"name": "Global",
"qcode": "Global",
},
{
'aliases': [],
'altids': {
'imatrics': '34017822-d341-3826-ab94-71d226d639c4',
},
'name': 'Genève',
'original_source': None,
'qcode': '34017822-d341-3826-ab94-71d226d639c4',
'scheme': 'place_custom',
'source': 'imatrics',
},
],
"object": [
{
Expand Down Expand Up @@ -331,6 +342,10 @@ def test_format_item(self):
"name": "Global",
"literal": "Global",
},
{
"name": 'Genève',
"literal": '34017822-d341-3826-ab94-71d226d639c4',
},
],
"taglines": [
"admin@example.com",
Expand Down
11 changes: 11 additions & 0 deletions server/ntb/tests/publish/ntb_nitf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,17 @@
"source": "imatrics",
"original_source": "1013",
},
{
'aliases': [],
'altids': {
'imatrics': '34017822-d341-3826-ab94-71d226d639c4',
},
'name': 'Genève',
'original_source': None,
'qcode': '34017822-d341-3826-ab94-71d226d639c4',
'scheme': 'place_custom',
'source': 'imatrics',
},
],
"object": [
{
Expand Down

0 comments on commit 147fa50

Please sign in to comment.