Skip to content

Commit

Permalink
feat: add biographien link to table
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Apr 12, 2024
1 parent bf18e51 commit 234f86f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apis_ontology/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ class Person(LegacyStuffMixin, LegacyDateMixin, AbstractEntity):
def __str__(self):
return f"{self.forename} {self.surname}"

@property
def biographien_urls(self):
base = "https://www.biographien.ac.at/oebl/oebl_"
links = [f"{base}{source.orig_filename[0]}/{source.orig_filename}" for source in self.sources.all() if source.orig_filename.endswith(".xml")]
return links


class Place(E53_Place, LegacyStuffMixin, LegacyDateMixin, AbstractEntity):
kind = models.CharField(max_length=255, blank=True, null=True)
Expand Down
7 changes: 7 additions & 0 deletions apis_ontology/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
from .models import Person


class BiographienLinkColumn(tables.TemplateColumn):
def __init__(self, *args, **kwargs):
template_name = "columns/biographien_link.html"
super().__init__(template_name=template_name, orderable=False, exclude_from_export=True, verbose_name="", empty_values=(), *args, **kwargs)


class PersonTable(AbstractEntityTable):
class Meta:
model = Person
Expand All @@ -14,6 +20,7 @@ class Meta:

surname = tables.LinkColumn("apis:apis_entities:generic_entities_edit_view", args=[A("self_contenttype.name"), A("pk")], empty_values=[],)
forename = tables.LinkColumn("apis:apis_entities:generic_entities_edit_view", args=[A("self_contenttype.name"), A("pk")], empty_values=[],)
biographien_link = BiographienLinkColumn()

def render_surname(self, record):
return record.surname or "No name"
Expand Down
3 changes: 3 additions & 0 deletions apis_ontology/templates/columns/biographien_link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for url in record.biographien_urls %}
<a href="{{ url }}">&#8599;</a>
{% endfor %}

0 comments on commit 234f86f

Please sign in to comment.