From 5d2e7c395f014b22ddb5985d079d81901716dab9 Mon Sep 17 00:00:00 2001 From: moanos Date: Fri, 31 May 2024 12:52:57 +0200 Subject: [PATCH] feat: Add position property that returns coordinates --- src/fellchensammlung/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index 3d3c53f..d037968 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -133,6 +133,13 @@ class AdoptionNotice(models.Model): def comments(self): return Comment.objects.filter(adoption_notice=self) + @property + def position(self): + if self.location is None: + return None + else: + return (self.location.longitude, self.location.latitude) + def get_absolute_url(self): """Returns the url to access a detailed page for the animal.""" return reverse('adoption-notice-detail', args=[str(self.id)])