Skip to content

Commit

Permalink
Merge pull request #173 from arthur-schnitzler/165-tei-export-of-writ…
Browse files Browse the repository at this point in the history
…ten-date

165 tei export of written date
  • Loading branch information
csae8092 authored Mar 7, 2024
2 parents 5400454 + 48842cc commit f323d36
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
9 changes: 9 additions & 0 deletions apis_core/apis_entities/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,12 @@ def test_029_parse_date(self):
for i, r in enumerate(results):
date_str = f"{r}"[:10]
self.assertEqual(date_str, x[1][i])

def test_030_clean_written_dates(self):
item = Person.objects.create(
start_date_written="1800<1812-01-04>", end_date_written="um 1900"
)
self.assertFalse("<" in item.clean_start_date_written())
self.assertFalse("<" in item.clean_end_date_written())
self.assertTrue("<" in item.start_date_written)
self.assertFalse("<" in item.end_date_written)
14 changes: 14 additions & 0 deletions apis_core/apis_metainfo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ def img_credit_label(self):
credit = "AKON"
return credit

def clean_start_date_written(self):
clean_date = self.start_date_written
if self.start_date_written:
if "<" in self.start_date_written:
clean_date = self.start_date_written.split("<")[0]
return clean_date

def clean_end_date_written(self):
clean_date = self.end_date_written
if self.end_date_written:
if "<" in self.end_date_written:
clean_date = self.end_date_written.split("<")[0]
return clean_date

@classmethod
def get_listview_url(self):
entity = self.__name__.lower()
Expand Down
4 changes: 2 additions & 2 deletions apis_core/apis_tei/templates/apis_tei/birth_death.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{% if object.start_end_date %}
notAfter-iso="{{ object.start_end_date|date:'Y-m-d' }}"
{% endif %}
>{{ object.start_date_written }}</date>
>{{ object.clean_start_date_written }}</date>
{% for x in birth_rel %}
{% if FULL %}
<settlement key="{{ x.related_place.id }}">
Expand Down Expand Up @@ -48,7 +48,7 @@
{% if object.end_end_date %}
notAfter-iso="{{ object.end_end_date|date:'Y-m-d' }}"
{% endif %}
>{{ object.end_date_written }}</date>
>{{ object.clean_end_date_written }}</date>
{% for x in death_rel %}
{% if FULL %}
<settlement key="{{ x.related_place.id }}">
Expand Down
8 changes: 4 additions & 4 deletions apis_core/apis_tei/templates/apis_tei/date.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if object.start_date_written == object.end_date_written %}
<date>{{ object.start_date_written }}</date>
<date>{{ object.clean_start_date_written }}</date>
{% elif object.start_date_written and object.end_date_written %}
<date
{% if object.start_start_date %}
Expand All @@ -8,7 +8,7 @@
{% if object.end_date %}
to-iso="{{ object.end_date|date:'Y-m-d' }}"
{% endif %}
>{{ object.start_date_written }} – {{ object.end_date_written }}</date>
>{{ object.clean_start_date_written }} – {{ object.clean_end_date_written }}</date>
{% elif object.start_date_written %}
<date
{% if object.start_start_date %}
Expand All @@ -17,7 +17,7 @@
{% if object.start_date %}
when-iso="{{ object.start_date|date:'Y-m-d' }}"
{% endif %}
>{{ object.start_date_written }}</date>
>{{ object.clean_start_date_written }}</date>
{% elif object.end_date_written %}
<date
{% if object.end_date %}
Expand All @@ -26,6 +26,6 @@
{% if object.end_end_date %}
notAfter-iso="{{ object.end_end_date|date:'Y-m-d' }}"
{% endif %}
>{{ object.end_date_written }}</date>
>{{ object.clean_end_date_written }}</date>
{% else %}
{% endif %}

0 comments on commit f323d36

Please sign in to comment.