From 929916dfbc725d4bb18b98cd78b9b2d020945fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Schl=C3=B6gl?= Date: Mon, 15 Jul 2024 10:37:44 +0200 Subject: [PATCH] fix: remove relations from lifepath vis resolves #137 also removes histogis shape for the moment --- paas_theme/api_views.py | 43 ++++++++++++++++++- paas_theme/static/theme/js/map.js | 18 ++++---- .../templates/theme/spacetime_graph.html | 2 +- paas_theme/urls.py | 1 + 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/paas_theme/api_views.py b/paas_theme/api_views.py index 4ea7992..02a2ee9 100644 --- a/paas_theme/api_views.py +++ b/paas_theme/api_views.py @@ -6,13 +6,14 @@ from .forms import PersonFacetedSearchFormNew from apis_core.api_routers import serializers_dict from apis_core.apis_relations.models import PersonInstitution, PersonPlace -from apis_core.apis_entities.models import Institution +from apis_core.apis_entities.models import Institution, Person from apis_core.api_renderers import NetJsonRenderer from django.conf import settings from copy import deepcopy from django.db.models import Q from .filters import KommissionenFilter from .serializers_analyse import KommissionZeitstrahl, KommissionenZeitstrahlNazis +from apis_core.apis_entities.serializers import LifePathSerializer from .provide_data import classes @@ -123,3 +124,43 @@ def get(self, request, format=None): ] rel_insts.extend(i1) return Response(res) + + +class LifePathMINEViewset(APIView): + def get(self, request, pk): + b_rel = [3090, 152, 64] + d_rel = [3054, 153, 3091] + pb_pd = b_rel + d_rel + lst_inst = list( + PersonInstitution.objects.filter( + Q(related_person_id=pk), + Q(start_date__isnull=False) | Q(end_date__isnull=False), + Q(relation_type_id__in=classes["berufslaufbahn_ids"] + [ + 1369, # absolvierte Studim an + 176 # schloss Schule ab + ]), + ).filter_for_user() + ) + lst_place = list( + PersonPlace.objects.filter( + Q(related_person_id=pk), + Q(start_date__isnull=False) + | Q(end_date__isnull=False) + | Q(relation_type_id__in=pb_pd), + ).filter_for_user() + ) + comb_lst = lst_inst + lst_place + p1 = Person.objects.get(pk=pk) + if p1.start_date: + for e in comb_lst: + if e.relation_type_id in b_rel: + e.start_date = p1.start_date + if p1.end_date: + for e in comb_lst: + if e.relation_type_id in d_rel: + e.start_date = p1.end_date + data = LifePathSerializer(comb_lst, many=True).data + data = [d for d in data if d is not None] + data = sorted(data, key=lambda i: i["year"]) + + return Response(data) \ No newline at end of file diff --git a/paas_theme/static/theme/js/map.js b/paas_theme/static/theme/js/map.js index 8a6e9ca..8f19154 100644 --- a/paas_theme/static/theme/js/map.js +++ b/paas_theme/static/theme/js/map.js @@ -227,18 +227,18 @@ function move_map() { //spacetime.style.paddingTop = `${document.querySelector('div.entry-header').offsetHeight}px` //bio.insertBefore(map_element, biotext); - add_histogis_shape() + //add_histogis_shape() map.invalidateSize() const caption = document.createElement("p") - caption.style.fontSize = '0.8em' - caption.style.fontStyle = 'italic' - caption.id = "mapcaption"; - caption.innerHTML = `Die Polygone werden dynamisch aus HistoGIS erstellt. - Es werden die administrativen Einheiten für die Position aller Marker zum Zeitpunkt ${date.toLocaleDateString('de-DE')} - (Mitte der bekannten Lebensspanne) geladen.` - //caption.appendChild(tnode) + // caption.style.fontSize = '0.8em' + // caption.style.fontStyle = 'italic' + // caption.id = "mapcaption"; + // caption.innerHTML = `Die Polygone werden dynamisch aus HistoGIS erstellt. + // Es werden die administrativen Einheiten für die Position aller Marker zum Zeitpunkt ${date.toLocaleDateString('de-DE')} + // (Mitte der bekannten Lebensspanne) geladen.` + // //caption.appendChild(tnode) - bio.insertBefore(caption, main); + // bio.insertBefore(caption, main); let max_icon = document.querySelector('#maplifelinebtn') max_icon.setAttribute('onclick', 'minimize_map()') max_icon.innerHTML = '' diff --git a/paas_theme/templates/theme/spacetime_graph.html b/paas_theme/templates/theme/spacetime_graph.html index 224b4fe..ec7c276 100644 --- a/paas_theme/templates/theme/spacetime_graph.html +++ b/paas_theme/templates/theme/spacetime_graph.html @@ -12,7 +12,7 @@ const padding = 0 const adj = 50 - const data = fetch('/apis/api2/lifepath/{{object.pk}}/') + const data = fetch('/api/lifepath/{{object.pk}}/') .then(response => response.json()) .then(drawLifepath) diff --git a/paas_theme/urls.py b/paas_theme/urls.py index d458426..660e41a 100644 --- a/paas_theme/urls.py +++ b/paas_theme/urls.py @@ -24,6 +24,7 @@ path(r"stories/", views.StoriesIndexPage.as_view(), name="stories_index"), path(r"api/network/", api_views.NetVizTheme.as_view()), path(r"api/egonetwork/", api_views.EgoNetwork.as_view()), + path(r"api/lifepath//", api_views.LifePathMINEViewset.as_view()), path( "paas/autocompletes/person/", autocompletes.PaasPersonAutocomplete.as_view(),