From 7eb323a295b10996ed14fef7e56ac2f3cd20daae Mon Sep 17 00:00:00 2001
From: csae8092
Date: Wed, 16 Oct 2024 13:58:07 +0200
Subject: [PATCH 1/6] #227
---
apis_core/apis_entities/detail_views.py | 1 -
notebooks/issue_227_theatre_titles.ipynb | 106 +++++++++++++++++++++++
set_env_variables.sh | 2 +-
3 files changed, 107 insertions(+), 2 deletions(-)
create mode 100644 notebooks/issue_227_theatre_titles.ipynb
diff --git a/apis_core/apis_entities/detail_views.py b/apis_core/apis_entities/detail_views.py
index 104047c..ee3bb3a 100644
--- a/apis_core/apis_entities/detail_views.py
+++ b/apis_core/apis_entities/detail_views.py
@@ -37,7 +37,6 @@ def get(self, request, *args, **kwargs):
table = get_generic_relations_table(
relation_class=rel, entity_instance=instance, detail=True
)
- print(match, entity)
if match[0] == entity:
link_to_relations = f"{rel.get_listview_url()}?source={pk}"
rel_type = match[1]
diff --git a/notebooks/issue_227_theatre_titles.ipynb b/notebooks/issue_227_theatre_titles.ipynb
new file mode 100644
index 0000000..67aa4f0
--- /dev/null
+++ b/notebooks/issue_227_theatre_titles.ipynb
@@ -0,0 +1,106 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "535b021a-300f-4140-96b6-5a50b96336bc",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# run against production 2024-10-16\n",
+ "from tqdm import tqdm\n",
+ "from dumper.utils import gsheet_to_df\n",
+ "from apis_core.utils import get_object_from_pk_or_uri"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "a914f665-cd8b-4698-8499-e4fb92c9f709",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df = gsheet_to_df(\"1wgLHBHeJECkmgJUIpPdG-JS8F-0ht_LdVTxNmWwW8O0\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "08aefefc-762f-4400-9893-1043d69ca874",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "col, _ = Collection.objects.get_or_create(name=\"Schnitzler-Theater\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "d6e188f0-371b-4527-8df1-3758d8eeee85",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# don't run twice!!!\n",
+ "pmb_ids = []\n",
+ "for i, row in tqdm(df.iterrows()):\n",
+ " work = Work.objects.create(name=row[\"Title\"])\n",
+ " pmb_ids.append(work.id)\n",
+ " work.collection.add(col)\n",
+ " uri, _ = Uri.objects.get_or_create(\n",
+ " uri=f'https://{row[\"URI\"]}',\n",
+ " domain=\"schnitzler-theater\",\n",
+ " entity=work\n",
+ " )"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "a845af15-a476-4e16-a8c1-ed33d1c7da86",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df[\"pmb_ids\"] = pmb_ids"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b682fa0f-4b92-4f90-b2c8-53d0f9f332a0",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df.to_csv(\"theater-uris.csv\", index=False)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "63d06a2d-bc85-4ae4-8142-a287f471a2fa",
+ "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.12.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/set_env_variables.sh b/set_env_variables.sh
index e0a3156..77758e8 100644
--- a/set_env_variables.sh
+++ b/set_env_variables.sh
@@ -1 +1 @@
-export $(grep -v '^#' .env | xargs)
\ No newline at end of file
+export $(grep -v '^#' .secret | xargs)
\ No newline at end of file
From d9da79bdb732a0e2d0d059e8e532cdd99e2ad521 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Anton=20M=C3=BCller?=
Date: Thu, 17 Oct 2024 10:53:41 +0200
Subject: [PATCH 2/6] fixed the titles for relation-views. changed the logo
placement in the relation dropdown menu
---
.../person_event_relation_views.py | 2 +-
.../person_institution_relation_views.py | 2 +-
.../person_person_relation_views.py | 2 +-
.../person_work_relation_views.py | 2 +-
templates/partials/navbar.html | 19 +++++++++----------
5 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/apis_core/apis_relations/person_event_relation_views.py b/apis_core/apis_relations/person_event_relation_views.py
index fd4eed9..84747aa 100644
--- a/apis_core/apis_relations/person_event_relation_views.py
+++ b/apis_core/apis_relations/person_event_relation_views.py
@@ -53,7 +53,7 @@ class PersonEventListView(GenericListView):
"target",
"crud",
]
- verbose_name = "Personen und Orte"
+ verbose_name = "Personen und Ereignisse"
exclude_columns = FIELDS_TO_EXCLUDE
enable_merge = False
template_name = "apis_relations/list_view.html"
diff --git a/apis_core/apis_relations/person_institution_relation_views.py b/apis_core/apis_relations/person_institution_relation_views.py
index 6e93b91..ed650d1 100644
--- a/apis_core/apis_relations/person_institution_relation_views.py
+++ b/apis_core/apis_relations/person_institution_relation_views.py
@@ -55,7 +55,7 @@ class PersonInstitutionListView(GenericListView):
"target",
"crud",
]
- verbose_name = "Personen und Orte"
+ verbose_name = "Personen und Institutionen"
exclude_columns = FIELDS_TO_EXCLUDE
enable_merge = False
template_name = "apis_relations/list_view.html"
diff --git a/apis_core/apis_relations/person_person_relation_views.py b/apis_core/apis_relations/person_person_relation_views.py
index ee3bb75..82b50a1 100644
--- a/apis_core/apis_relations/person_person_relation_views.py
+++ b/apis_core/apis_relations/person_person_relation_views.py
@@ -53,7 +53,7 @@ class PersonPersonListView(GenericListView):
"target",
"crud",
]
- verbose_name = "Personen und Orte"
+ verbose_name = "Personen und Personen"
exclude_columns = FIELDS_TO_EXCLUDE
enable_merge = False
template_name = "apis_relations/list_view.html"
diff --git a/apis_core/apis_relations/person_work_relation_views.py b/apis_core/apis_relations/person_work_relation_views.py
index 36ec738..98b7fcf 100644
--- a/apis_core/apis_relations/person_work_relation_views.py
+++ b/apis_core/apis_relations/person_work_relation_views.py
@@ -53,7 +53,7 @@ class PersonWorkListView(GenericListView):
"target",
"crud",
]
- verbose_name = "Personen und Orte"
+ verbose_name = "Personen und Werke"
exclude_columns = FIELDS_TO_EXCLUDE
enable_merge = False
template_name = "apis_relations/list_view.html"
diff --git a/templates/partials/navbar.html b/templates/partials/navbar.html
index 9913826..9e0a00e 100644
--- a/templates/partials/navbar.html
+++ b/templates/partials/navbar.html
@@ -79,37 +79,36 @@
- Personen und Personen
-
+ Personen und Personen
- Personen und Orte
-
+ Personen und Orte
+
- Personen und Werke
-
+ Personen und Werke
+
- Personen und Events
-
+ Personen und Events
+
- Personen und Institutionen
-
+ Personen und Institutionen
+
From 7027bccb23f88e482964eb6ccb6853ddcafa7bd0 Mon Sep 17 00:00:00 2001
From: csae8092
Date: Fri, 18 Oct 2024 13:44:20 +0200
Subject: [PATCH 3/6] Personen und Orte -> Personen und Institutionen for
person-instituion list view
---
notebooks/issue__213.ipynb | 145 +++++++++++++++++++++++++++++++++++++
1 file changed, 145 insertions(+)
create mode 100644 notebooks/issue__213.ipynb
diff --git a/notebooks/issue__213.ipynb b/notebooks/issue__213.ipynb
new file mode 100644
index 0000000..67df55f
--- /dev/null
+++ b/notebooks/issue__213.ipynb
@@ -0,0 +1,145 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "abdba1e8-027e-4931-a35b-03aaf8aa9464",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from django.core.exceptions import ObjectDoesNotExist\n",
+ "from tqdm import tqdm\n",
+ "from dumper.utils import gsheet_to_df\n",
+ "from apis_core.utils import get_object_from_pk_or_uri"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "cdb36196-46aa-4b7b-9871-0a8a3dd279ea",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df = gsheet_to_df(\"1-_WXbdmpLzz_9vBiZ1y9v2tle_26m4tAhPTGzkkin5E\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "682d2d62-1e30-4db5-8323-c07a3f62222e",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "342c4e3d-39c5-4f8b-b0b0-950cde457983",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "relation_type_lookup = {\n",
+ " \"1049\": {\n",
+ " \"relation_type\":PersonWork,\n",
+ " \"relation\": PersonWorkRelation.objects.get(id=1049),\n",
+ " \"target_class\": Work\n",
+ " },\n",
+ " \"1052\": {\n",
+ " \"relation_type\": PersonWork,\n",
+ " \"relation\": PersonWorkRelation.objects.get(id=1052),\n",
+ " \"target_class\": Work\n",
+ " },\n",
+ " \"1053\": {\n",
+ " \"relation_type\": PersonWork,\n",
+ " \"relation\": PersonWorkRelation.objects.get(id=1053),\n",
+ " \"target_class\": Work\n",
+ " },\n",
+ " \"1181\": {\n",
+ " \"relation_type\": PersonPlace,\n",
+ " \"relation\": PersonPlaceRelation.objects.get(id=1181),\n",
+ " \"target_class\": Place\n",
+ " },\n",
+ " \"1217\": {\n",
+ " \"relation_type\": PersonWork,\n",
+ " \"relation\": PersonWorkRelation.objects.get(id=1217),\n",
+ " \"target_class\": Work\n",
+ " }\n",
+ "}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6748b522-2617-4436-ab9b-0c46c1867e6a",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "does_not_exist = set()\n",
+ "for g, ndf in df.groupby(\"relation-id\"):\n",
+ " relation = relation_type_lookup[str(g)][\"relation\"]\n",
+ " relation_class = relation_type_lookup[str(g)][\"relation_type\"]\n",
+ " target_class = relation_type_lookup[str(g)][\"target_class\"]\n",
+ " print(relation, relation_class, target_class)\n",
+ " if \"ork\" in relation_class.__name__:\n",
+ " print(\"work\")\n",
+ " else:\n",
+ " print(\"place\")\n",
+ " for i, row in tqdm(ndf.iterrows(), total=len(ndf)):\n",
+ " try:\n",
+ " source = Person.objects.get(pk=row[\"source_id\"])\n",
+ " except ObjectDoesNotExist:\n",
+ " does_not_exist.add(row[\"source_id\"])\n",
+ " continue\n",
+ " try:\n",
+ " target = target_class.objects.get(pk=row[\"target_id\"])\n",
+ " except ObjectDoesNotExist:\n",
+ " does_not_exist.add(row[\"target_id\"])\n",
+ " if isinstance(row[\"relation_start_date_written\"], str):\n",
+ " start_date_written = row[\"relation_start_date_written\"]\n",
+ " end_date_written = row[\"relation_end_date_written\"]\n",
+ " else:\n",
+ " start_date_written = None\n",
+ " end_date_written = None\n",
+ " if \"ork\" in relation_class.__name__:\n",
+ " relation_class.objects.get_or_create(\n",
+ " related_person=source,\n",
+ " related_work=target,\n",
+ " relation_type=relation,\n",
+ " start_date_written=start_date_written,\n",
+ " end_date_written=end_date_written\n",
+ " )\n",
+ " else:\n",
+ " relation_class.objects.get_or_create(\n",
+ " related_person=source,\n",
+ " related_place=target,\n",
+ " relation_type=relation,\n",
+ " start_date_written=start_date_written,\n",
+ " end_date_written=end_date_written\n",
+ " )\n"
+ ]
+ }
+ ],
+ "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.12.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
From cd7860f491032b63a55f07b3627edc0df55333c3 Mon Sep 17 00:00:00 2001
From: csae8092
Date: Tue, 22 Oct 2024 09:08:48 +0200
Subject: [PATCH 4/6] minor [skip ci]
---
set_env_variables.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/set_env_variables.sh b/set_env_variables.sh
index 77758e8..e0a3156 100644
--- a/set_env_variables.sh
+++ b/set_env_variables.sh
@@ -1 +1 @@
-export $(grep -v '^#' .secret | xargs)
\ No newline at end of file
+export $(grep -v '^#' .env | xargs)
\ No newline at end of file
From 8421328344bb842878156a03841dbc19d117bf6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Anton=20M=C3=BCller?=
Date: Thu, 24 Oct 2024 10:48:20 +0200
Subject: [PATCH 5/6] da hat ein Komma gefehlt
---
.../apis_entities/templates/apis_entities/confirm_delete.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apis_core/apis_entities/templates/apis_entities/confirm_delete.html b/apis_core/apis_entities/templates/apis_entities/confirm_delete.html
index a616931..31bf42a 100644
--- a/apis_core/apis_entities/templates/apis_entities/confirm_delete.html
+++ b/apis_core/apis_entities/templates/apis_entities/confirm_delete.html
@@ -9,10 +9,10 @@ Ganz sicher?
{% csrf_token %}
From a28a80b3b0f6785c85c59d317d595c401e5dc632 Mon Sep 17 00:00:00 2001
From: csae8092
Date: Sat, 26 Oct 2024 09:22:48 +0200
Subject: [PATCH 6/6] default relation order in relation list view set to last
modified
---
apis_core/apis_relations/models.py | 4 ++++
apis_core/apis_relations/utils.py | 1 +
2 files changed, 5 insertions(+)
diff --git a/apis_core/apis_relations/models.py b/apis_core/apis_relations/models.py
index f10a251..4d70e18 100644
--- a/apis_core/apis_relations/models.py
+++ b/apis_core/apis_relations/models.py
@@ -337,6 +337,10 @@ def get_related_entity_field_nameb(cls):
class PersonPerson(AbstractRelation):
+ @classmethod
+ def get_icon(self):
+ return "bi bi-people apis-person"
+
@classmethod
def get_second_icon(self):
return "bi bi-people apis-person"
diff --git a/apis_core/apis_relations/utils.py b/apis_core/apis_relations/utils.py
index abd5898..fe7e126 100644
--- a/apis_core/apis_relations/utils.py
+++ b/apis_core/apis_relations/utils.py
@@ -73,6 +73,7 @@ class MyTable(tables.Table):
class Meta:
model = MyModelClass
+ order_by = "-updated"
sequence = (
"id",
"source",