From 0dd141ca9540ee002f8deb483b214490aed12f2b Mon Sep 17 00:00:00 2001 From: csae8092 Date: Thu, 7 Mar 2024 09:30:18 +0100 Subject: [PATCH 1/8] closes #166 --- issue__166_bahruris.ipynb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/issue__166_bahruris.ipynb b/issue__166_bahruris.ipynb index 5150cc3..92333f2 100644 --- a/issue__166_bahruris.ipynb +++ b/issue__166_bahruris.ipynb @@ -12,6 +12,23 @@ "from apis_core.utils import get_object_from_pk_or_uri" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "2af62ef5", + "metadata": {}, + "outputs": [], + "source": [ + "# yet another try, run 2024-03-07\n", + "\n", + "uris = Uri.objects.filter(uri__icontains=\"bahr-textverzeichnis.acdh.oeaw.ac.at/pmb\")\n", + "print(uris.count())\n", + "for x in tqdm(uris):\n", + " x.domain = \"bahr-textverzeichnis\"\n", + " x.save()\n", + "Uri.objects.filter(domain=\"bahr-textverzeichnis\").count()" + ] + }, { "cell_type": "code", "execution_count": null, From ccbcc4a5f25bbfcc6243e94bbb4a6e10196ebb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Anton=20M=C3=BCller?= Date: Fri, 8 Mar 2024 09:17:05 +0100 Subject: [PATCH 2/8] Hinweis auf das Wikidata-Property --- dumper/templates/dumper/about.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dumper/templates/dumper/about.html b/dumper/templates/dumper/about.html index 9ac8150..e21bd84 100644 --- a/dumper/templates/dumper/about.html +++ b/dumper/templates/dumper/about.html @@ -45,6 +45,11 @@

DatenherkunftIntertextuality in the Legal Papers of Karl Kraus – A Scholarly Digital Edition, link (2019–2022) +

2024 kam es zu einem größeren Update der Software. Bugs und Probleme sind nunmehr auf GitHub + verzeichnet. Zum gleichen Zeitpunkt richtete Emmanuel Maria Dammerer ein eigenes + Property für die PMB in Wikidata ein, so dass nun Einträge in der PMB auch unkompliziert + in Wikidata verzeichnet werden können: P12483. Im Zuge des Abgleichs konnte er zudem viele + Datenfehler, vorwiegend Dubletten, zurückspielen, die wir in Folge behoben haben.

* Der Name ist ein Sonderfall eines Akronyms. Er versteht sich als Referenz auf Peter Michael Braunwarth, dessen Arbeit den Grundstock bildet.

From bd98c33a9400b0a26b0d82168d2b2304fcb5c03c Mon Sep 17 00:00:00 2001 From: csae8092 Date: Sat, 9 Mar 2024 08:02:53 +0100 Subject: [PATCH 3/8] closes #169 [skip ci] --- issue__169_merging.ipynb | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/issue__169_merging.ipynb b/issue__169_merging.ipynb index 479513b..86e0b54 100644 --- a/issue__169_merging.ipynb +++ b/issue__169_merging.ipynb @@ -7,8 +7,9 @@ "metadata": {}, "outputs": [], "source": [ + "# rerun 2024-04-09\n", "# run 2024-04-05\n", - "\n", + "from tqdm import tqdm\n", "from apis_core.utils import get_object_from_pk_or_uri\n", "from dumper.utils import gsheet_to_df" ] @@ -30,7 +31,7 @@ "metadata": {}, "outputs": [], "source": [ - "for i, row in df.iterrows():\n", + "for i, row in tqdm(df.iterrows()):\n", " keep = get_object_from_pk_or_uri(row[\"ID\"])\n", " remove = get_object_from_pk_or_uri(row[\"merge\"])\n", " try:\n", @@ -38,24 +39,6 @@ " except Exception as e:\n", " print(keep.id, remove.id, e)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "de1484e7", - "metadata": {}, - "outputs": [], - "source": [ - "df" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "906e6c5c", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From ea06678828a62cc8d2d8e3d921c9a60ed05814d8 Mon Sep 17 00:00:00 2001 From: csae8092 Date: Tue, 12 Mar 2024 15:46:08 +0100 Subject: [PATCH 4/8] minor [skip ci] --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5cef35b..1c70bfd 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ maybe in future also with PMB CRUD included `python manage.py process_beacon --beacon=https://thun-korrespondenz.acdh.oeaw.ac.at/beacon.txt --domain=thun-korrespondenz` +`python manage.py process_beacon --beacon=https://raw.githubusercontent.com/Auden-Musulin-Papers/amp-entities/main/out/beacon.txt --domain=Auden-Musulin-Papers` + +`python manage.py process_beacon --beacon=https://raw.githubusercontent.com/Hanslick-Online/hsl-entities/main/out/beacon.txt --domain=Hanslick` + ## set up new instance From 2d0db838390f3a524bde7a632aa27d9c3b51e2ad Mon Sep 17 00:00:00 2001 From: csae8092 Date: Tue, 12 Mar 2024 17:11:46 +0100 Subject: [PATCH 5/8] added colors to domain mapping --- dumper/management/commands/fix_domains.py | 3 ++- dumper/utils.py | 19 --------------- normdata/utils.py | 2 +- pmb/settings.py | 28 +++++++++++++++++++++++ 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/dumper/management/commands/fix_domains.py b/dumper/management/commands/fix_domains.py index e3a7233..c576f5b 100644 --- a/dumper/management/commands/fix_domains.py +++ b/dumper/management/commands/fix_domains.py @@ -6,13 +6,14 @@ from tqdm import tqdm from apis_core.apis_metainfo.models import Uri -from dumper.utils import DOMAIN_MAPPING, write_report +from dumper.utils import write_report class Command(BaseCommand): help = "Command to harmonize URL-Domains" def handle(self, *args, **kwargs): + DOMAIN_MAPPING = settings.DOMAIN_MAPPING start_time = datetime.now().strftime(settings.PMB_TIME_PATTERN) print("start fixing domains") domains = [x[1] for x in DOMAIN_MAPPING] diff --git a/dumper/utils.py b/dumper/utils.py index c05f303..542a6f7 100644 --- a/dumper/utils.py +++ b/dumper/utils.py @@ -11,25 +11,6 @@ from apis_core.apis_metainfo.models import Uri -DOMAIN_MAPPING = [ - ("d-nb.info/gnd", "gnd"), - ("geonames", "geonames"), - ("wikidata", "wikidata"), - ("wikipedia", "wikipedia"), - ("fackel.oeaw.ac.at", "fackel"), - ("schnitzler-tagebuch", "schnitzler-tagebuch"), - ("schnitzler-bahr", "schnitzler-bahr"), - ("schnitzler-briefe", "schnitzler-briefe"), - ("schnitzler-lektueren", "schnitzler-lektueren"), - ("//doi.org/10.1553", "oebl"), - ("dx.doi.org/10.1553", "oeml"), - ("kraus.wienbibliothek.at", "legalkraus"), - ("kraus1933", "dritte-walpurgisnacht"), - ("pmb.acdh.oeaw.ac.at", "pmb"), - ("anno", "anno"), - ("geschichtewiki.wien", "wiengeschichtewiki"), -] - PMB_ENTITIES = "pmb_entities" diff --git a/normdata/utils.py b/normdata/utils.py index 32d4583..0891baf 100644 --- a/normdata/utils.py +++ b/normdata/utils.py @@ -12,8 +12,8 @@ from apis_core.apis_metainfo.models import Uri from apis_core.apis_relations.models import PersonPlace from apis_core.apis_vocabularies.models import PersonPlaceRelation -from dumper.utils import DOMAIN_MAPPING +DOMAIN_MAPPING = settings.DOMAIN_MAPPING BIRTH_REL = getattr(settings, "BIRTH_REL") DEATH_REL = getattr(settings, "DEATH_REL") diff --git a/pmb/settings.py b/pmb/settings.py index 345c95e..ef660f5 100644 --- a/pmb/settings.py +++ b/pmb/settings.py @@ -306,3 +306,31 @@ DJANGO_VITE = { "default": {"dev_mode": VITE_DEV, "manifest_path": "static/vite/manifest.info"} } + +DEFAULT_COLOR = "#9B5F98" +DOMAIN_MAPPING = [ + ("d-nb.info", "gnd", "#006AB3"), + ("geonames", "geonames", "##363"), + ("wikidata", "wikidata", "#0645ad"), + ("wikipedia", "wikipedia", DEFAULT_COLOR), + ("fackel.oeaw.ac.at", "fackel", "#CE0F0B"), + ("schnitzler-tagebuch", "schnitzler-tagebuch", "#037a33"), + ("schnitzler-bahr", "schnitzler-bahr", "#F9BD63"), + ("schnitzler-briefe", "schnitzler-briefe", "#A63437"), + ("schnitzler-lektueren", "schnitzler-lektueren", "#022954"), + ("schnitzler-interviews", "schnitzler-interviews", "#3D5A80"), + ("schnitzler-kino.", "schnitzler-kino", "#B43C9C"), + ("//doi.org/10.1553", "oebl", "#a50021"), + ("dx.doi.org/10.1553", "oeml", DEFAULT_COLOR), + ("kraus.wienbibliothek.at", "legalkraus", "#c85545"), + ("kraus1933", "dritte-walpurgisnacht", "#a21a17"), + ("pmb.acdh.oeaw.ac.at", "pmb", DEFAULT_COLOR), + ("anno", "anno", DEFAULT_COLOR), + ("geschichtewiki.wien", "wiengeschichtewiki", DEFAULT_COLOR), + ("thun-korrespondenz.acdh.oeaw.ac.at", "thun-korrespondenz", DEFAULT_COLOR), + ("hanslick.acdh.oeaw.ac.at", "hanslick-online", DEFAULT_COLOR), + ("bahr-textverzeichnis.acdh.oeaw.ac.at/pmb", "bahr-textverzeichnis", "#8E4162"), + ("bahr-textverzeichnis.acdh.oeaw.ac.at/TSN-", "bahr-TSN", DEFAULT_COLOR), + ("amp.acdh.oeaw.ac.at", "auden-musulin-papers", DEFAULT_COLOR), + +] From f17f89a52fbef6ecafab534649c133a33a162eee Mon Sep 17 00:00:00 2001 From: csae8092 Date: Tue, 12 Mar 2024 17:20:22 +0100 Subject: [PATCH 6/8] color to the links --- .../detail_views/entity_detail_generic.html | 2 +- apis_core/apis_metainfo/models.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html b/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html index 3d88965..d865c36 100644 --- a/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html +++ b/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html @@ -137,7 +137,7 @@

{% for x in object.uri_set.all %} - {{ x }} {% if user.is_authenticated %} + {{ x }} {% if user.is_authenticated %} | diff --git a/apis_core/apis_metainfo/models.py b/apis_core/apis_metainfo/models.py index 38525db..4aa2186 100644 --- a/apis_core/apis_metainfo/models.py +++ b/apis_core/apis_metainfo/models.py @@ -18,6 +18,10 @@ from apis_core.helper_functions import DateParser +DOMAIN_MAPPING = settings.DOMAIN_MAPPING +DEFAULT_COLOR = settings.DEFAULT_COLOR + + class TempEntityClass(models.Model): """Base class to bind common attributes to many classes. @@ -294,9 +298,7 @@ def merge_with(self, entities): if not isinstance(entities, list) and not isinstance(entities, QuerySet): entities = [entities] entities = [ - self_model_class.objects.get(pk=ent) - if type(ent) == int - else ent # noqa: E721 + self_model_class.objects.get(pk=ent) if type(ent) == int else ent # noqa: E721 for ent in entities ] rels = ContentType.objects.filter( @@ -459,6 +461,14 @@ class Uri(models.Model): def __str__(self): return str(self.uri) + def get_color(self): + color = DEFAULT_COLOR + for x in DOMAIN_MAPPING: + if x[1] == self.domain: + color = x[2] + break + return color + def get_web_object(self): result = { "relation_pk": self.pk, From d326afcdc327a5808f53e85e6bd00fbf0b701729 Mon Sep 17 00:00:00 2001 From: csae8092 Date: Tue, 12 Mar 2024 18:37:55 +0100 Subject: [PATCH 7/8] badges with domain for labels ToDo: tests --- .../detail_views/entity_detail_generic.html | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html b/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html index d865c36..0431b83 100644 --- a/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html +++ b/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html @@ -133,15 +133,30 @@

- URI + PMB-URI + + + https://pmb.acdh.oeaw.ac.at/entity/{{ object.id }}/ + + + + + Verknüpfte Datensätze {% for x in object.uri_set.all %} - {{ x }} {% if user.is_authenticated %} - - | - - {% endif %}
+ {% if user.is_authenticated %} + + {{ x }} {% if user.is_authenticated %} + + | + + {% endif %}
+ {% else %} + {% if x.domain != "pmb" %} + {{ x.domain }} + {% endif %} + {% endif %} {% endfor %} From 8fe233cdcf1b8ed24cba9b9b9d24561fc3f3451a Mon Sep 17 00:00:00 2001 From: csae8092 Date: Tue, 12 Mar 2024 18:54:53 +0100 Subject: [PATCH 8/8] tests for uri colors --- apis_core/apis_entities/tests.py | 15 +++++++++++++++ apis_core/apis_metainfo/models.py | 4 +++- pmb/settings.py | 1 - 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apis_core/apis_entities/tests.py b/apis_core/apis_entities/tests.py index aa17897..ab75b17 100644 --- a/apis_core/apis_entities/tests.py +++ b/apis_core/apis_entities/tests.py @@ -1,5 +1,6 @@ from AcdhArcheAssets.uri_norm_rules import get_normalized_uri from django.apps import apps +from django.conf import settings from django.contrib.auth.models import User from django.test import Client, TestCase from django.urls import reverse @@ -425,3 +426,17 @@ def test_030_clean_written_dates(self): self.assertFalse("<" in item.clean_end_date_written()) self.assertTrue("<" in item.start_date_written) self.assertFalse("<" in item.end_date_written) + + def test_031_get_colo(self): + DEFAULT_COLOR = settings.DEFAULT_COLOR + DOMAIN_MAPPING = settings.DOMAIN_MAPPING + item = Person.objects.create(name="hansi4ever") + for x in DOMAIN_MAPPING[:3]: + uri = Uri.objects.create( + uri=f"https://{x[0]}/sumsi.com", domain=x[1], entity=item + ) + self.assertEqual(uri.get_color(), x[2]) + uri = Uri.objects.create( + uri="https://whatdoicare/123.at", domain="somethingveryrandom", entity=item + ) + self.assertEqual(uri.get_color(), DEFAULT_COLOR) diff --git a/apis_core/apis_metainfo/models.py b/apis_core/apis_metainfo/models.py index 4aa2186..697eb00 100644 --- a/apis_core/apis_metainfo/models.py +++ b/apis_core/apis_metainfo/models.py @@ -298,7 +298,9 @@ def merge_with(self, entities): if not isinstance(entities, list) and not isinstance(entities, QuerySet): entities = [entities] entities = [ - self_model_class.objects.get(pk=ent) if type(ent) == int else ent # noqa: E721 + self_model_class.objects.get(pk=ent) + if type(ent) == int + else ent # noqa: E721 for ent in entities ] rels = ContentType.objects.filter( diff --git a/pmb/settings.py b/pmb/settings.py index ef660f5..8ac0507 100644 --- a/pmb/settings.py +++ b/pmb/settings.py @@ -332,5 +332,4 @@ ("bahr-textverzeichnis.acdh.oeaw.ac.at/pmb", "bahr-textverzeichnis", "#8E4162"), ("bahr-textverzeichnis.acdh.oeaw.ac.at/TSN-", "bahr-TSN", DEFAULT_COLOR), ("amp.acdh.oeaw.ac.at", "auden-musulin-papers", DEFAULT_COLOR), - ]