feat: Add position property that returns coordinates

This commit is contained in:
moanos [he/him] 2024-05-31 12:52:57 +02:00
parent fb9ed07abc
commit 5d2e7c395f

View File

@ -133,6 +133,13 @@ class AdoptionNotice(models.Model):
def comments(self): def comments(self):
return Comment.objects.filter(adoption_notice=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): def get_absolute_url(self):
"""Returns the url to access a detailed page for the animal.""" """Returns the url to access a detailed page for the animal."""
return reverse('adoption-notice-detail', args=[str(self.id)]) return reverse('adoption-notice-detail', args=[str(self.id)])