summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/birds/admin.py3
-rw-r--r--app/birds/migrations/0001_initial.py86
-rw-r--r--app/birds/migrations/0002_auto_20160313_0953.py26
-rw-r--r--app/birds/migrations/0003_birdsighting_images.py21
-rw-r--r--app/birds/migrations/__init__.py0
-rw-r--r--app/birds/models.py14
-rw-r--r--app/locations/models.py6
7 files changed, 154 insertions, 2 deletions
diff --git a/app/birds/admin.py b/app/birds/admin.py
index ff2db93..09b511a 100644
--- a/app/birds/admin.py
+++ b/app/birds/admin.py
@@ -39,7 +39,8 @@ class BirdSightingAdmin(OSMGeoAdmin):
'point',
'date',
'image',
- 'seen_by'
+ 'seen_by',
+ 'images',
),
'classes': (
'show',
diff --git a/app/birds/migrations/0001_initial.py b/app/birds/migrations/0001_initial.py
new file mode 100644
index 0000000..0e18574
--- /dev/null
+++ b/app/birds/migrations/0001_initial.py
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2016-03-13 09:49
+from __future__ import unicode_literals
+
+import birds.models
+from django.conf import settings
+import django.contrib.gis.db.models.fields
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('locations', '__first__'),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Bird',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('common_name', models.CharField(max_length=200)),
+ ('slug', models.SlugField()),
+ ('scientific_name', models.CharField(max_length=200)),
+ ('code', models.IntegerField(choices=[(1, 'regular occurring - common'), (2, 'regular occurring - less common'), (3, 'rare'), (4, 'casual'), (5, 'accidental'), (6, 'Cannot be found')], default=0)),
+ ('image', models.FileField(blank=True, null=True, upload_to=birds.models.get_upload_path)),
+ ],
+ options={
+ 'ordering': ['common_name'],
+ },
+ ),
+ migrations.CreateModel(
+ name='BirdAudio',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('audio', models.FileField(upload_to='audio/birds/')),
+ ('recorder', models.CharField(blank=True, max_length=200, null=True)),
+ ('pub_date', models.DateTimeField()),
+ ('location', models.CharField(blank=True, max_length=200, null=True)),
+ ('link', models.CharField(blank=True, max_length=450, null=True)),
+ ('copyright', models.CharField(blank=True, max_length=250, null=True)),
+ ('bird', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='recordings', to='birds.Bird')),
+ ],
+ options={
+ 'ordering': ['bird'],
+ 'verbose_name_plural': 'Bird Audio',
+ },
+ ),
+ migrations.CreateModel(
+ name='BirdClass',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('common_name', models.CharField(max_length=200)),
+ ('scientific_name', models.CharField(max_length=200)),
+ ],
+ options={
+ 'ordering': ['common_name'],
+ 'verbose_name_plural': 'Bird Class',
+ },
+ ),
+ migrations.CreateModel(
+ name='BirdSighting',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('point', django.contrib.gis.db.models.fields.PointField(srid=4326)),
+ ('date', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Date')),
+ ('image', models.FileField(blank=True, null=True, upload_to=birds.models.get_upload_path)),
+ ('bird', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='birds.Bird')),
+ ('location', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Location')),
+ ('seen_by', models.ManyToManyField(to=settings.AUTH_USER_MODEL)),
+ ],
+ options={
+ 'verbose_name_plural': 'Bird Sighting',
+ },
+ ),
+ migrations.AddField(
+ model_name='bird',
+ name='bird_class',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='birds.BirdClass'),
+ ),
+ ]
diff --git a/app/birds/migrations/0002_auto_20160313_0953.py b/app/birds/migrations/0002_auto_20160313_0953.py
new file mode 100644
index 0000000..a2085ea
--- /dev/null
+++ b/app/birds/migrations/0002_auto_20160313_0953.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2016-03-13 09:53
+from __future__ import unicode_literals
+
+import birds.models
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('birds', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='bird',
+ name='image_credit',
+ field=models.CharField(blank=True, max_length=200, null=True),
+ ),
+ migrations.AlterField(
+ model_name='bird',
+ name='image',
+ field=models.FileField(blank=True, help_text='width of high res is 1360px', null=True, upload_to=birds.models.get_upload_path),
+ ),
+ ]
diff --git a/app/birds/migrations/0003_birdsighting_images.py b/app/birds/migrations/0003_birdsighting_images.py
new file mode 100644
index 0000000..d20e8b7
--- /dev/null
+++ b/app/birds/migrations/0003_birdsighting_images.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2016-03-20 08:02
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('photos', '0007_auto_20160320_0802'),
+ ('birds', '0002_auto_20160313_0953'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='birdsighting',
+ name='images',
+ field=models.ManyToManyField(to='photos.LuxImage'),
+ ),
+ ]
diff --git a/app/birds/migrations/__init__.py b/app/birds/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/birds/migrations/__init__.py
diff --git a/app/birds/models.py b/app/birds/models.py
index dc2aa19..05a1159 100644
--- a/app/birds/models.py
+++ b/app/birds/models.py
@@ -8,6 +8,7 @@ from locations.models import Location
from django import forms
from django.conf import settings
+from photos.models import LuxImage
def get_upload_path(self, filename):
return "images/bird-images/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
@@ -42,11 +43,21 @@ class Bird(models.Model):
scientific_name = models.CharField(max_length=200)
code = models.IntegerField(choices=ABA_CODES, default=0)
bird_class = models.ForeignKey(BirdClass)
- image = models.FileField(upload_to=get_upload_path, null=True, blank=True)
+ image = models.FileField(upload_to=get_upload_path, null=True, blank=True, help_text="width of high res is 1360px")
+ image_credit = models.CharField(max_length=200, blank=True, null=True)
def __str__(self):
return self.common_name
+ # function to resize large image to 680px wide and use as normal image
+ # the question is, should this happen here, or with some universale image
+ # model that can be attached to other models, loaded in entries and
+ # displayed in galleries. I suppose the answer is yes then isn't it?
+ # the problem is that I still can't see exactly what that looks like...
+
+ def get_image_url(self):
+ return "%s%s" % (settings.IMAGES_URL, self.image.url.split("media")[1][8:])
+
def get_absolute_url(self):
return reverse("birds:detail", kwargs={"slug": self.slug})
@@ -82,6 +93,7 @@ class BirdSighting(models.Model):
date = models.DateTimeField('Date', default=timezone.now)
image = models.FileField(upload_to=get_upload_path, null=True, blank=True)
seen_by = models.ManyToManyField(User)
+ images = models.ManyToManyField(LuxImage)
class Meta:
verbose_name_plural = 'Bird Sighting'
diff --git a/app/locations/models.py b/app/locations/models.py
index a56299e..b4ee2af 100644
--- a/app/locations/models.py
+++ b/app/locations/models.py
@@ -129,6 +129,12 @@ class Location(models.Model):
def __str__(self):
return self.name
+ def comma_name(self):
+ if self.state.country.name == "United States":
+ return self.state
+ else:
+ return self.state.country
+
def get_absolute_url(self):
return "/locations/%s/%s/%s/" % (self.state.country.slug, self.state.slug, self.slug)