From 528239a8da6d67de2d7655d9cd2eb05054bb1017 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Thu, 8 May 2014 19:48:44 -0400 Subject: added birding app for real this time --- app/birds/models.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 app/birds/models.py (limited to 'app/birds/models.py') diff --git a/app/birds/models.py b/app/birds/models.py new file mode 100644 index 0000000..4f7ae51 --- /dev/null +++ b/app/birds/models.py @@ -0,0 +1,43 @@ +import datetime +from django.contrib.gis.db import models +from locations.models import BirdingLocation + +def get_upload_path(self, filename): + return "images/bird-images/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename) + +#from http://aba.org/checklist/codes.html +ABA_CODES = ( + (1, 'regular occurring - common'), + (2, 'regular occurring - less common'), + (3, 'rare'), + (4, 'casual'), + (5, 'accidental'), + (6, 'Cannot be found'), + ) + + +class BirdClass(models.Model): + common_name = models.CharField(max_length=200) + scientific_name = models.CharField(max_length=200) + + class Meta: + verbose_name_plural = 'Bird Class' + + def __str__(self): + return self.common_name + +class Bird(models.Model): + common_name = models.CharField(max_length=200) + scientific_name = models.CharField(max_length=200) + code = models.IntegerField(choices=ABA_CODES, default=0) + bird_class = models.ForeignKey(BirdClass) + + def __str__(self): + return self.common_name + +class BirdSighting(models.Model): + bird = models.ForeignKey(Bird) + location = models.ForeignKey(BirdingLocation) + date = models.DateTimeField('Date') + image = models.FileField(upload_to=get_upload_path, null=True,blank=True) + -- cgit v1.2.3-70-g09d2