summaryrefslogtreecommitdiff
path: root/app/locations
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2018-09-05 10:30:12 -0500
committerluxagraf <sng@luxagraf.net>2018-09-05 10:30:12 -0500
commitefabaed1ef7ec2baafabed9dfd3c08dc192d98bd (patch)
tree26088187308c165007cbc1947346b7a7d35c9635 /app/locations
parent7c5521b47e8fa3aa2f768571959f45e4fdcccf00 (diff)
added total_price to campsite admin
Diffstat (limited to 'app/locations')
-rw-r--r--app/locations/admin.py2
-rw-r--r--app/locations/models.py10
2 files changed, 10 insertions, 2 deletions
diff --git a/app/locations/admin.py b/app/locations/admin.py
index f185e97..01da84d 100644
--- a/app/locations/admin.py
+++ b/app/locations/admin.py
@@ -248,7 +248,7 @@ class CheckInAdmin(OLAdminBase):
@admin.register(Campsite)
class CampsiteAdmin(OLAdminBase):
form = LGEntryForm
- list_display = ('name', 'location', 'date_arrived', 'date_left', 'campsite_type', 'campsite_price', 'nights_stayed')
+ list_display = ('name', 'location', 'date_arrived', 'date_left', 'campsite_type', 'total_price', 'nights_stayed')
list_filter = ('date_arrived', 'campsite_type')
search_fields = ['location__name', ]
fieldsets = (
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: