From 5038a05bcd12df7288fbb4ef114f44f7f2410825 Mon Sep 17 00:00:00 2001 From: Alexander Watzinger Date: Wed, 7 Aug 2024 15:34:38 +0200 Subject: [PATCH] Fetching additional information from GND --- openatlas/api/external/gnd.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/openatlas/api/external/gnd.py b/openatlas/api/external/gnd.py index dea566a2a..804ba4e43 100644 --- a/openatlas/api/external/gnd.py +++ b/openatlas/api/external/gnd.py @@ -3,6 +3,15 @@ import requests from flask import g +from openatlas.display.util import link + + +def print_values(values: dict[str: str]) -> str: + items = [] + for item in values: + items.append(link(item["label"], item["id"], external=True)) + return '
'.join(items) + def fetch_gnd(id_: str) -> dict[str, Any]: url = f'{g.gnd.resolver_url}{id_}.json' @@ -13,4 +22,17 @@ def fetch_gnd(id_: str) -> dict[str, Any]: return {} if 'preferredName' in data: info['preferred name'] = data['preferredName'] + if 'gender' in data: + info['gender'] = print_values(data['gender']) + if 'dateOfBirth' in data: + info['date of birth'] = data['dateOfBirth'] + if 'placeOfBirth' in data: + info['place of birth'] = print_values(data['placeOfBirth']) + if 'dateOfDeath' in data: + info['date of death'] = data['dateOfDeath'] + if 'placeOfDeath' in data: + info['place of death'] = print_values(data['placeOfDeath']) + if 'type' in data: + info['type'] = '
'.join(data['type']) + return info