diff --git a/apis_core/apis_entities/list_view_person.py b/apis_core/apis_entities/list_view_person.py index 39cbe67..6dce4cc 100644 --- a/apis_core/apis_entities/list_view_person.py +++ b/apis_core/apis_entities/list_view_person.py @@ -182,6 +182,14 @@ def __init__(self, *args, **kwargs): class PersonTable(tables.Table): id = tables.LinkColumn(verbose_name="ID") + start_date_written = tables.TemplateColumn( + "{{ record.start_date|date:'Y' }}", + verbose_name="Geburtsjahr", + ) + end_date_written = tables.TemplateColumn( + "{{ record.end_date|date:'Y' }}", + verbose_name="Todesjahr", + ) personplace_set = tables.ManyToManyColumn( verbose_name="Geburtsort", transform=lambda x: x.related_place, @@ -209,8 +217,8 @@ class PersonListView(GenericListView): "name", "first_name", "uris", - "start_date", - "end_date", + "start_date_written", + "end_date_written", "personplace_set", ] exclude_columns = excluded_cols diff --git a/apis_core/apis_entities/list_view_work.py b/apis_core/apis_entities/list_view_work.py index ea67746..818eade 100644 --- a/apis_core/apis_entities/list_view_work.py +++ b/apis_core/apis_entities/list_view_work.py @@ -135,6 +135,10 @@ def __init__(self, *args, **kwargs): class WorkTable(tables.Table): id = tables.LinkColumn(verbose_name="ID") name = tables.columns.Column(verbose_name="Titel") + start_date_written = tables.TemplateColumn( + "{{ record.start_date|date:'Y' }}", + verbose_name="Erscheinungsjahr", + ) label_set = tables.ManyToManyColumn(verbose_name="Labels") personwork_set = tables.ManyToManyColumn( verbose_name="AutorIn", @@ -163,7 +167,7 @@ class WorkListView(GenericListView): init_columns = [ "id", "name", - "start_date", + "start_date_written", "personwork_set", "kind", ] 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 99418d1..c2a6eac 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 @@ -5,7 +5,7 @@ {% block content %} {% include "partials/entity_styles.html" %} -
+
@@ -51,33 +51,21 @@

-
-
-

- - - - {% if entity_type != 'event' %}| {% endif %} -

- {% if object.img_url %} - +
+
+
- + Bild von {{ object }} + {% if object.img_credit %} +
{{ object.img_credit_label }}
+ {% endif %} + -
+ Abbildung - Bild von {{ object }} - {% if object.img_credit %} -
{{ object.img_credit_label }}
- {% endif %} -
- - - {% endif %} {% block info-table %} - - {% if no_merge_labels %} - {% endif %} - - {% if object.start_date or object.end_date %} - {% endif %} - {% if object.lat %} - - - - - {% endif %} -
+ Titel @@ -86,23 +74,18 @@

+ Labels -
    {% for x in no_merge_labels %} -
  • - {{ x.label_type }}: {{ x.label }} -
  • + {{ x.label_type }}: {{ x.label }}
    {% endfor %} -
-
+ ID @@ -110,7 +93,7 @@

+ Typ @@ -119,7 +102,7 @@

+ Datum @@ -132,40 +115,40 @@

- Länge/Breite - - {{ object.lat }} / {{ object.lng }} -
{% endblock info-table %} {% block info-metadata %} - - - - - + + + + + {% if entity_type != 'event' %} + + + + + {% endif %} + + + + {% if object.collection.all %} - - -
- URI - - {% for x in object.uri_set.all %} - {{ x }} {% if user.is_authenticated %} - - | - - {% endif %}
- {% endfor %} -
JSON-EXPORT + +
TEI/XML-EXPORT
+ URI + + {% for x in object.uri_set.all %} + {{ x }} {% if user.is_authenticated %} + + | + + {% endif %}
+ {% endfor %} +
Sammlungen + {% for x in object.collection.all %} {{ x }}
{% endfor %} @@ -175,7 +158,7 @@

{% endif %} {% if object.notes %}

+ Anmerkungen @@ -185,7 +168,7 @@

{% endif %} {% if object.references %}

+ Belege @@ -198,6 +181,7 @@

{% block left-pane-additional %} {% endblock left-pane-additional %} +

Beziehungen

{% block relations %} @@ -205,7 +189,7 @@

Beziehungen

{% if obj.1.data|length > 0 %}

{{ obj.0 }}

-
+
{% render_table obj.1 %}
{% endif %} diff --git a/apis_core/apis_entities/templates/apis_entities/detail_views/person_detail.html b/apis_core/apis_entities/templates/apis_entities/detail_views/person_detail.html index 79ff2c9..5774664 100644 --- a/apis_core/apis_entities/templates/apis_entities/detail_views/person_detail.html +++ b/apis_core/apis_entities/templates/apis_entities/detail_views/person_detail.html @@ -1,9 +1,8 @@ {% extends "apis_entities/detail_views/entity_detail_generic.html" %} {% block info-table %} - - {% if no_merge_labels %} - {% endif %} - - {% if object.start_date or object.end_date %} - - {% endif %} -
+ Name @@ -12,7 +11,7 @@
+ anderer Name @@ -26,7 +25,7 @@
+ ID @@ -34,7 +33,7 @@
+ Gender @@ -43,7 +42,7 @@
+ Zeit @@ -58,7 +57,7 @@ {% endif %} {% if object.profession.all %}
+ Berufe @@ -68,5 +67,4 @@
{% endblock info-table %} diff --git a/apis_core/apis_entities/templates/apis_entities/detail_views/place_detail.html b/apis_core/apis_entities/templates/apis_entities/detail_views/place_detail.html index ad0ade2..19f179a 100644 --- a/apis_core/apis_entities/templates/apis_entities/detail_views/place_detail.html +++ b/apis_core/apis_entities/templates/apis_entities/detail_views/place_detail.html @@ -16,10 +16,10 @@ marker.bindPopup("{{ object.name }}").openPopup(); {% endif %} - + {% if no_merge_labels %} - {% endif %} - - - + {% if object.start_date_written or object.end_date_written %} - + {% endif %} -
+ Alternative Namen @@ -33,7 +33,7 @@
+ ID @@ -41,7 +41,7 @@
+ Koordinaten @@ -49,15 +49,14 @@
OrtstypeOrtstype {% if object.kind.description %} {{ object.kind }} {{ object.kind.description }} {% else %} {{ object.kind }} {% endif %}
von – bisvon – bis {% if object.start_date_written %}{{ object.start_date_written }}{% endif %}{% if object.end_date_written %} – {{ object.end_date_written }}{% endif %}
{% endblock info-table %} diff --git a/issue__17_dataimports_part2.ipynb b/issue__17_dataimports_part2.ipynb new file mode 100644 index 0000000..9cb61cf --- /dev/null +++ b/issue__17_dataimports_part2.ipynb @@ -0,0 +1,195 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "d7335a42", + "metadata": {}, + "outputs": [], + "source": [ + "from acdh_tei_pyutils.tei import TeiReader\n", + "from tqdm import tqdm\n", + "from icecream import ic\n", + "from normdata.utils import import_from_normdata" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "dd68245d", + "metadata": {}, + "outputs": [], + "source": [ + "source_file = \"https://github.com/hermann-bahr/bahr-index/raw/main/tsn/listPerson_TSN_1.xml\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "570aec42", + "metadata": {}, + "outputs": [], + "source": [ + "doc = TeiReader(source_file)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "070e76d4", + "metadata": {}, + "outputs": [], + "source": [ + "nsmap = doc.nsmap\n", + "bahr_url = \"https://hermanbahrtextverzeichnis/\"\n", + "bahr_domain = \"hermanbahrtextverzeichnis\"\n", + "bahr_col, _ = Collection.objects.get_or_create(name=\"Bahr Textverzeichnis\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b6d54fa4", + "metadata": {}, + "outputs": [], + "source": [ + "no_gnd = set()\n", + "no_wikidata = set()\n", + "not_created = set()\n", + "for x in tqdm(doc.any_xpath(\".//tei:person\")):\n", + " entity = False\n", + " hbtv_uri = x.xpath(\".//tei:idno[@type='TSN']/text()\", namespaces=nsmap)[0]\n", + " hbtv_url = f\"{bahr_url}{hbtv_uri}\"\n", + " try:\n", + " gnd = x.xpath(\".//tei:idno[@type='gnd']/text()\", namespaces=nsmap)[0]\n", + " entity = import_from_normdata(gnd, 'person')\n", + " except IndexError:\n", + " no_gnd.add(hbtv_uri)\n", + " try:\n", + " wikidata = x.xpath(\".//tei:idno[@type='wikidata']/text()\", namespaces=nsmap)[0]\n", + " wikidata_url = f\"http://www.wikidata.org/entity/{wikidata}\"\n", + " entity = import_from_normdata(wikidata_url, 'person')\n", + " except IndexError:\n", + " no_wikidata.add(hbtv_uri)\n", + " not_created.add(hbtv_uri)\n", + " if entity:\n", + " entity.collection.add(bahr_col)\n", + " uri, _ = Uri.objects.get_or_create(uri=hbtv_url, domain=bahr_domain)\n", + " uri.entity = entity\n", + " uri.save()\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "08ac5108", + "metadata": {}, + "outputs": [], + "source": [ + "print(\"no import entities without normdata records\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aa7a2300", + "metadata": {}, + "outputs": [], + "source": [ + "for x in tqdm(doc.any_xpath(\".//tei:person\")):\n", + " if len(x.xpath(\".//tei:idno\", namespaces=nsmap)) == 1:\n", + " hbtv_uri = x.xpath(\".//tei:idno[@type='TSN']/text()\", namespaces=nsmap)[0]\n", + " hbtv_url = f\"{bahr_url}{hbtv_uri}\"\n", + " uri, _ = Uri.objects.get_or_create(uri=hbtv_url, domain=bahr_domain)\n", + " if uri.entity:\n", + " continue\n", + " else:\n", + " try:\n", + " name = x.xpath(\"./tei:persName[1]/tei:surname[1]/text()\", namespaces=nsmap)[0]\n", + " except IndexError:\n", + " name = \"\"\n", + " try:\n", + " first_name = x.xpath(\"./tei:persName[1]/tei:forename[1]/text()\", namespaces=nsmap)[0]\n", + " except IndexError:\n", + " first_name = \"\"\n", + " try:\n", + " start_date_written = x.xpath(\"./tei:birth/tei:date/text()\", namespaces=nsmap)[0]\n", + " except IndexError:\n", + " start_date_written = \"\"\n", + " try:\n", + " end_date_written = x.xpath(\"./tei:death/tei:date/text()\", namespaces=nsmap)[0]\n", + " except IndexError:\n", + " end_date_written = \"\"\n", + " try:\n", + " gender = x.xpath(\"./tei:sex\", namespaces=nsmap)[0]\n", + " gender = gender.attrib[\"value\"]\n", + " except IndexError:\n", + " gender = \"\"\n", + " entity = Person.objects.create(\n", + " name=name,\n", + " first_name=first_name,\n", + " start_date_written=start_date_written,\n", + " end_date_written=end_date_written,\n", + " gender=gender\n", + " )\n", + " entity.collection.add(bahr_col)\n", + " uri.entity = entity\n", + " uri.save()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "40ff7ca2", + "metadata": {}, + "outputs": [], + "source": [ + "for x in tqdm(doc.any_xpath(\".//tei:person[./tei:occupation]\")):\n", + " hbtv_uri = x.xpath(\".//tei:idno[@type='TSN']/text()\", namespaces=nsmap)[0]\n", + " hbtv_url = f\"{bahr_url}{hbtv_uri}\"\n", + " try:\n", + " uri = Uri.objects.get(uri=hbtv_url, domain=bahr_domain)\n", + " except:\n", + " ic(hbtv_url)\n", + " try:\n", + " entity = uri.entity.get_child_entity()\n", + " except:\n", + " ic(uri)\n", + " continue\n", + " for o in x.xpath(\"./tei:occupation/text()\", namespaces=nsmap):\n", + " profession, _ = ProfessionType.objects.get_or_create(name=o)\n", + " entity.profession.add(profession)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "77e897d5", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Django Shell-Plus", + "language": "python", + "name": "django_extensions" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/pmb/settings.py b/pmb/settings.py index f33f23a..29a5e0b 100644 --- a/pmb/settings.py +++ b/pmb/settings.py @@ -23,7 +23,9 @@ APIS_LIST_VIEWS_ALLOWED = True APIS_DETAIL_VIEWS_ALLOWED = True DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap5.html" - +DJANGO_TABLES2_TABLE_ATTRS = { + 'class': 'table table-hover table-borderless', +} # Application definition INSTALLED_APPS = [ diff --git a/static/css/style.css b/static/css/style.css index ddf0e49..dd77419 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -18,9 +18,9 @@ a { text-decoration: unset; } -a:hover { +a:hover { color: var(--pmb-hover) -} +} main { padding-top: 5.50em; @@ -101,6 +101,6 @@ main { margin-left: .75rem; } -.left-width { - width: 100px; -} +.table-borderless { + border: none; +} \ No newline at end of file