From: Matthijs Kooijman Date: Tue, 19 Oct 2010 13:02:45 +0000 (+0200) Subject: tickets: Add a (virtual) Booking.price property. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=33f124ba84a2ed9acc0f34fef1112882498e6551;p=matthijs%2Fprojects%2Fdorestad-bookings.git tickets: Add a (virtual) Booking.price property. --- diff --git a/tickets/models.py b/tickets/models.py index f022e6f..5c56b0a 100644 --- a/tickets/models.py +++ b/tickets/models.py @@ -1,3 +1,5 @@ +# coding=utf-8 + from django.db import models # Create your models here. @@ -9,6 +11,8 @@ SHOW_CHOICES = [ ("vrijdag", "vrijdag 17 december, 20:00") TICKETS_CHOICES = [ (n, n) for n in range(1, 6)] +TICKET_PRICE=10 + class Booking(models.Model): created = models.DateTimeField(auto_now_add=True, editable=False, verbose_name="Datum") name = models.CharField(max_length=100, verbose_name="Naam") @@ -18,3 +22,7 @@ class Booking(models.Model): tickets = models.IntegerField(choices=TICKETS_CHOICES, verbose_name="Aantal kaarten") show = models.CharField(max_length=50, choices=SHOW_CHOICES, verbose_name="Voorstelling") payment = models.DateTimeField(blank=True, null=True, verbose_name="Betaling vewerkt op") + + def _get_price(self): + return self.tickets * TICKET_PRICE + price = property(_get_price)