summaryrefslogtreecommitdiff
path: root/app/birds/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2014-05-08 19:48:44 -0400
committerluxagraf <sng@luxagraf.net>2014-05-08 19:48:44 -0400
commit528239a8da6d67de2d7655d9cd2eb05054bb1017 (patch)
tree2a8783daa864a9ba11d2dede7b223a17bf97e185 /app/birds/models.py
parentc54417f2eb53c2bbeff7e94acef688c97cd949d5 (diff)
added birding app for real this time
Diffstat (limited to 'app/birds/models.py')
-rw-r--r--app/birds/models.py43
1 files changed, 43 insertions, 0 deletions
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)
+