diff --git a/ynr/apps/elections/uk/templates/candidates/person-view.html b/ynr/apps/elections/uk/templates/candidates/person-view.html
index 3f9c4244e..e48a7e6f4 100644
--- a/ynr/apps/elections/uk/templates/candidates/person-view.html
+++ b/ynr/apps/elections/uk/templates/candidates/person-view.html
@@ -127,6 +127,7 @@
Personal details:
{% if person.biography %}
Statement to voters
{{ person.biography|linebreaks }}
+ This statement was last updated on {{ person.biography_updated_at }}
{% endif %}
Candidacies:
diff --git a/ynr/apps/people/models.py b/ynr/apps/people/models.py
index ddaaa64ea..65225893b 100644
--- a/ynr/apps/people/models.py
+++ b/ynr/apps/people/models.py
@@ -1,5 +1,5 @@
import contextlib
-from datetime import date
+from datetime import date, datetime
from enum import Enum, unique
from urllib.parse import quote_plus, urljoin
@@ -917,6 +917,32 @@ def create_person_image(self, queued_image, copyright):
# as a recent edit by API consumers
self.save()
+ def biography_updated_at(self):
+ """This property calculates the timestamp for
+ the last date the biography was changed."""
+
+ biography_versions = []
+ versions = self.versions
+ for version in versions:
+ if version["data"]["biography"]:
+ biography_versions.append(version)
+
+ biography_version = max(
+ biography_versions, key=lambda x: x["timestamp"]
+ )
+
+ if not biography_version:
+ return None
+
+ timestamp_str = biography_version["data"]["timestamp"]
+ try:
+ # Convert the string to a datetime object
+ datetime_obj = datetime.fromisoformat(timestamp_str)
+ print("Converted DateTime:", datetime_obj)
+ except ValueError as e:
+ print("Error:", e)
+ return biography_version["timestamp"]
+
class PersonNameSynonym(models.Model):
class Meta: