Skip to content

Commit

Permalink
Merge pull request #205 from acdh-oeaw/ms/137-remove-membership-and-p…
Browse files Browse the repository at this point in the history
…otentially-others-relation-from-the-lifespan-visualization

fix: remove relations from lifepath vis
  • Loading branch information
sennierer authored Jul 15, 2024
2 parents 45afeb1 + 929916d commit 74ba8a7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
43 changes: 42 additions & 1 deletion paas_theme/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
18 changes: 9 additions & 9 deletions paas_theme/static/theme/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="https://histogis.acdh.oeaw.ac.at">HistoGIS</a> 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 <a href="https://histogis.acdh.oeaw.ac.at">HistoGIS</a> 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 = '<i data-feather="minimize-2"></i>'
Expand Down
2 changes: 1 addition & 1 deletion paas_theme/templates/theme/spacetime_graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions paas_theme/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<int:pk>/", api_views.LifePathMINEViewset.as_view()),
path(
"paas/autocompletes/person/",
autocompletes.PaasPersonAutocomplete.as_view(),
Expand Down

0 comments on commit 74ba8a7

Please sign in to comment.