diff --git a/apis_core/apis_entities/views.py b/apis_core/apis_entities/views.py index f1b44b9..1ded29b 100644 --- a/apis_core/apis_entities/views.py +++ b/apis_core/apis_entities/views.py @@ -60,7 +60,10 @@ def get(self, request, *args, **kwargs): objects = objects[:20] disable_sort = True table = get_generic_relations_table( - relation_class=rel, entity_instance=instance, detail=False, disable_sort=disable_sort + relation_class=rel, + entity_instance=instance, + detail=False, + disable_sort=disable_sort, ) tb_object = table(data=objects, prefix=prefix) tb_object_open = request.GET.get(prefix + "page", None) @@ -73,7 +76,7 @@ def get(self, request, *args, **kwargs): tb_object_open, link_to_relations, disable_sort, - object_count + object_count, ) ) form = get_entities_form(entity.title()) diff --git a/apis_core/apis_metainfo/views.py b/apis_core/apis_metainfo/views.py index a091bb8..1b75dd9 100644 --- a/apis_core/apis_metainfo/views.py +++ b/apis_core/apis_metainfo/views.py @@ -1,12 +1,15 @@ +import json +import pandas as pd from typing import Any from django.conf import settings from django.contrib.auth.decorators import login_required -from django.http import HttpResponse +from django.http import HttpResponse, Http404, JsonResponse from django.urls import reverse_lazy from django.utils.decorators import method_decorator from django.views.generic.detail import DetailView from django.views.generic.edit import DeleteView + from browsing.browsing_utils import BaseCreateView, BaseUpdateView from .forms import UriForm @@ -39,6 +42,35 @@ def wikidata_beacon(request): return HttpResponse(result, content_type="text/plain") +def domain_uris(request, domain): + df = pd.DataFrame( + list( + Uri.objects.filter(domain__icontains=domain).values( + "uri", "entity_id", "entity__name" + ) + ) + ) + if df.empty: + raise Http404 + df["entity_id"] = df.apply( + lambda x: f"https://pmb.acdh.oeaw.ac.at/entity/{x['entity_id']}", axis=1 + ) + format = request.GET.get("format", "csv") + if format not in ["csv", "json"]: + format = "csv" + if format == "csv": + response = HttpResponse( + content_type="text/csv", + headers={"Content-Disposition": f'attachment; filename="{domain}.csv"'}, + ) + df.to_csv(response, index=False) + else: + df = df.set_index("uri") + out = df.to_json(orient="index") + response = JsonResponse(json.loads(out)) + return response + + class UriDetailView(DetailView): model = Uri template_name = "apis_metainfo/uri_detail.html" diff --git a/apis_core/urls.py b/apis_core/urls.py index 9635d88..294ff66 100644 --- a/apis_core/urls.py +++ b/apis_core/urls.py @@ -5,7 +5,7 @@ from rest_framework import routers from apis_core.api_routers import views -from apis_core.apis_metainfo.views import beacon, wikidata_beacon +from apis_core.apis_metainfo.views import beacon, wikidata_beacon, domain_uris from apis_core.apis_vocabularies.api_views import UserViewSet from apis_core.helper_functions.ContentType import GetContentTypes from apis_core.apis_entities.autocomplete3 import GenericEntitiesAutocomplete @@ -45,6 +45,7 @@ ), path("gnd-beacon/", beacon, name="beacon"), path("wikidata-beacon/", wikidata_beacon, name="wikidata_beacon"), + path("domain-uris/", domain_uris, name="domain_uris"), path("labels/", include("apis_core.apis_labels.urls", namespace="apis_labels")), path("tei/", include("apis_core.apis_tei.tei_urls", namespace="apis_tei")), path( diff --git a/dumper/templates/dumper/about.html b/dumper/templates/dumper/about.html index 2c23642..4cb202e 100644 --- a/dumper/templates/dumper/about.html +++ b/dumper/templates/dumper/about.html @@ -459,6 +459,11 @@

URIs

href="{% url 'apis_core:wikidata_beacon' %}">BEACON Datei bezogen werden.

Wikipedia-Einträge werden nicht direkt verlinkt. Auf der linken Seite im Menü eines Wikipedia-Eintrags steht ein Link auf das entsprechende Wikidata-Objekt.

+

Konkordanz-Listen zwischen Projekt-URIS und PMB-URIs können nach diesem Schema heruntergeladen werden: https://pmb.acdh.oeaw.ac.at/apis/domain-uris/{projekt-uri-domain}, also z.B: +

Zur Personensuche

Wien