From f8e9854c45f6d19debec891d7854a6c4cb0724a1 Mon Sep 17 00:00:00 2001 From: Gytha Ogg Date: Tue, 25 Jun 2024 15:19:02 +0200 Subject: [PATCH] Add dates to author active at place --- apis_ontology/tables.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/apis_ontology/tables.py b/apis_ontology/tables.py index dd8d736..869f533 100644 --- a/apis_ontology/tables.py +++ b/apis_ontology/tables.py @@ -330,3 +330,28 @@ def render_work_author(self, value): if work.author_id: return f"{work.author_name} ({work.author_id})" return "" + + +class PersonActiveAtPlaceTable(TibScholRelationMixinTable): + class Meta(TibScholRelationMixinTable.Meta): + fields = [ + "subj", + "obj", + "author_dates", + "edit", + "delete", + ] + + subj = tables.Column(verbose_name="Person") + author_dates = tables.Column( + verbose_name="Lifespan", orderable=False, accessor="subj" + ) + obj = tables.Column(verbose_name="Place") + + def render_author_dates(self, value): + author = Person.objects.get(pk=value.pk) + return ( + (author.start_date_written if author.start_date_written else "") + + " - " + + (author.end_date_written if author.end_date_written else "") + )