From d7feab58fe9eedfc32dbbe9c0a7117b02ec79513 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 22 Dec 2014 14:25:55 +0100 Subject: [PATCH] Add Duck model skeleton --- booking/models.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/booking/models.py b/booking/models.py index a9de518..689c31e 100644 --- a/booking/models.py +++ b/booking/models.py @@ -1,5 +1,6 @@ from django.db import models from django.contrib.auth.models import User +from django.utils import timezone class Species(models.Model): """Model to hold the Ducks’ species""" @@ -26,3 +27,23 @@ class Competence(models.Model): def __str__(self): return self.name + +class Duck(models.Model): + """Model to hold Duck data""" + + name = models.CharField(max_length = 80, null = True, blank = True) + color = models.CharField(max_length = 6) + species = models.ForeignKey(Species) + location = models.ForeignKey(Location) + donated_by = models.ForeignKey(User) + donated_at = models.DateTimeField(default = timezone.now) + adopted_by = models.ForeignKey(User, related_name = 'adopted_ducks', null = True) + adopted_at = models.DateTimeField(null = True) + on_holiday_since = models.DateTimeField(null = True) + on_holiday_until = models.DateTimeField(null = True) + + def __str__(self): + if self.name == None or self.name == '': + return 'Unnamed :(' + + return self.name