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

fix formatter for places with missing wikidata id #465

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
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
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',
},
devketanpro marked this conversation as resolved.
Show resolved Hide resolved
],
"object": [
{
Expand Down
Loading