Skip to content

Commit

Permalink
Merge pull request #77 from arthur-schnitzler/main
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
csae8092 authored Mar 13, 2024
2 parents e00e1f3 + 72e0447 commit ef9f582
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 47 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,30 @@ <h2>
</tr>
<tr>
<th class="w-25">
URI
PMB-URI
</th>
<td>
<a href="https://pmb.acdh.oeaw.ac.at/entity/{{ object.id }}/">https://pmb.acdh.oeaw.ac.at/entity/{{ object.id }}/</a>
</td>
</tr>
<tr>
<th class="w-25">
Verknüpfte Datensätze
</th>
<td>
{% for x in object.uri_set.all %}
<a href="{{ x }}">{{ x }}</a> {% if user.is_authenticated %} <a href="{{ x.get_edit_url }}" title="URI bearbeiten">
<i class="bi bi-pencil-square"></i>
</a> | <a href="{{ x.get_delete_url }}" title="URI löschen">
<i class="bi bi-trash3"></i>
</a>{% endif %}<br />
{% if user.is_authenticated %}

<a href="{{ x }}" style="color:{{ x.get_color }}">{{ x }}</a> {% if user.is_authenticated %} <a href="{{ x.get_edit_url }}" title="URI bearbeiten">
<i class="bi bi-pencil-square"></i>
</a> | <a href="{{ x.get_delete_url }}" title="URI löschen">
<i class="bi bi-trash3"></i>
</a>{% endif %}<br />
{% else %}
{% if x.domain != "pmb" %}
<a class="m2 fs-5" href="{{ x }}" style="color:{{ x.get_color }}"><span class="badge" style="background-color:{{ x.get_color }}">{{ x.domain }}</span></a>
{% endif %}
{% endif %}
{% endfor %}
</td>
</tr>
Expand Down
15 changes: 15 additions & 0 deletions apis_core/apis_entities/tests.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
12 changes: 12 additions & 0 deletions apis_core/apis_metainfo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -459,6 +463,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,
Expand Down
3 changes: 2 additions & 1 deletion dumper/management/commands/fix_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions dumper/templates/dumper/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ <h2 id="datenherkunf">Datenherkunft<a class="anchor-link" href="#datenherkunft"
<li>Intertextuality in the Legal Papers of Karl Kraus – A Scholarly Digital Edition, <a
href="https://www.kraus.wienbibliothek.at">link</a> (2019–2022)</li>
</ul>
<p>2024 kam es zu einem größeren Update der Software. Bugs und Probleme sind nunmehr auf <a href="https://github.com/arthur-schnitzler/pmb-service/issues">GitHub</a>
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: <a href="https://www.wikidata.org/wiki/Property:P12483">P12483</a>. Im Zuge des Abgleichs konnte er zudem viele
Datenfehler, vorwiegend Dubletten, zurückspielen, die wir in Folge behoben haben. </p>
<p>* <i>Der Name ist ein Sonderfall eines Akronyms. Er versteht sich als Referenz auf Peter
Michael Braunwarth, dessen Arbeit den Grundstock bildet.</i></p>

Expand Down
19 changes: 0 additions & 19 deletions dumper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
17 changes: 17 additions & 0 deletions issue__166_bahruris.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 3 additions & 20 deletions issue__169_merging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand All @@ -30,32 +31,14 @@
"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",
" keep.merge_with(remove.id)\n",
" 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": {
Expand Down
2 changes: 1 addition & 1 deletion normdata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
27 changes: 27 additions & 0 deletions pmb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,30 @@
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),
]

0 comments on commit ef9f582

Please sign in to comment.