diff options
Diffstat (limited to 'app/locations/models.py')
-rw-r--r-- | app/locations/models.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/locations/models.py b/app/locations/models.py index 6745ff2..24b3234 100644 --- a/app/locations/models.py +++ b/app/locations/models.py @@ -245,13 +245,21 @@ class Campsite(models.Model): def lat(self): '''Get the site's latitude.''' return self.point.y - + @property def nights_stayed(self): '''Get the number of nights we spent there ''' delta = self.date_left - self.date_arrived return delta.days + @property + def total_price(self): + '''Get the price and total price for display in admin ''' + if not self.campsite_price: + price = 0 + total = self.nights_stayed * price + return "{0} ({1}/night)".format(total, self.campsite_price) + def save(self, *args, **kwargs): created = self.pk is None if not created: |