summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2017-07-16 09:44:13 -0600
committerluxagraf <sng@luxagraf.net>2017-07-16 09:44:13 -0600
commit6eeb020f226110a42a7d3d68b04244dbc03ecfde (patch)
treec2ef92cdbe706de21f12fb432fa4d3c8dab30a88
parentd295b55359e0f507775aba62f29a76de077bfca1 (diff)
updated birds app for faster bird adding
-rw-r--r--app/birds/admin.py4
-rw-r--r--app/birds/autocomplete_light_registry.py24
-rw-r--r--app/birds/migrations/0005_auto_20170714_2222.py25
-rw-r--r--app/birds/migrations/0006_auto_20170714_2224.py25
-rw-r--r--app/birds/models.py5
-rw-r--r--design/sass/_homepage.scss1
6 files changed, 81 insertions, 3 deletions
diff --git a/app/birds/admin.py b/app/birds/admin.py
index e70f9db..aa2aabb 100644
--- a/app/birds/admin.py
+++ b/app/birds/admin.py
@@ -34,8 +34,10 @@ class BirdAdmin(admin.ModelAdmin):
class BirdSightingAdmin(OSMGeoAdmin):
form = GalleryForm
+ list_filter = (
+ )
list_display = ('bird', 'location')
- list_filter = ('seen_by', 'location',)
+ list_filter = ('seen_by',('location', admin.RelatedOnlyFieldListFilter),)
fieldsets = (
('Sighting', {
'fields': (
diff --git a/app/birds/autocomplete_light_registry.py b/app/birds/autocomplete_light_registry.py
new file mode 100644
index 0000000..1cfa881
--- /dev/null
+++ b/app/birds/autocomplete_light_registry.py
@@ -0,0 +1,24 @@
+import autocomplete_light.shortcuts as al
+from .models import Bird
+
+# This will generate a PersonAutocomplete class
+al.register(Bird,
+ # Just like in ModelAdmin.search_fields
+ search_fields=['common_name','scientific_name'],
+ attrs={
+ # This will set the input placeholder attribute:
+ 'placeholder': 'Tags...',
+ # This will set the yourlabs.Autocomplete.minimumCharacters
+ # options, the naming conversion is handled by jQuery
+ 'data-autocomplete-minimum-characters': 1,
+},
+ # This will set the data-widget-maximum-values attribute on the
+ # widget container element, and will be set to
+ # yourlabs.Widget.maximumValues (jQuery handles the naming
+ # conversion).
+ widget_attrs={
+ 'data-widget-maximum-values': 4,
+ # Enable modern-style widget !
+ 'class': 'modern-style',
+ },
+)
diff --git a/app/birds/migrations/0005_auto_20170714_2222.py b/app/birds/migrations/0005_auto_20170714_2222.py
new file mode 100644
index 0000000..8bdfb4b
--- /dev/null
+++ b/app/birds/migrations/0005_auto_20170714_2222.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2017-07-14 22:22
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('birds', '0004_auto_20160321_1123'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='birdsighting',
+ name='audio',
+ field=models.ManyToManyField(blank=True, null=True, to='birds.BirdAudio'),
+ ),
+ migrations.AlterField(
+ model_name='birdsighting',
+ name='images',
+ field=models.ManyToManyField(blank=True, null=True, to='photos.LuxImage'),
+ ),
+ ]
diff --git a/app/birds/migrations/0006_auto_20170714_2224.py b/app/birds/migrations/0006_auto_20170714_2224.py
new file mode 100644
index 0000000..bd4db82
--- /dev/null
+++ b/app/birds/migrations/0006_auto_20170714_2224.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2017-07-14 22:24
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('birds', '0005_auto_20170714_2222'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='birdsighting',
+ name='audio',
+ field=models.ManyToManyField(blank=True, to='birds.BirdAudio'),
+ ),
+ migrations.AlterField(
+ model_name='birdsighting',
+ name='images',
+ field=models.ManyToManyField(blank=True, to='photos.LuxImage'),
+ ),
+ ]
diff --git a/app/birds/models.py b/app/birds/models.py
index fc2ce30..380e602 100644
--- a/app/birds/models.py
+++ b/app/birds/models.py
@@ -89,7 +89,7 @@ class BirdAudio(models.Model):
class BirdSighting(models.Model):
bird = models.ForeignKey(Bird)
- point = models.PointField()
+ point = models.PointField(blank=True)
location = models.ForeignKey(Location, blank=True)
date = models.DateTimeField('Date', default=timezone.now)
seen_by = models.ManyToManyField(User)
@@ -98,6 +98,7 @@ class BirdSighting(models.Model):
class Meta:
verbose_name_plural = 'Bird Sighting'
+ get_latest_by = 'date'
@property
def state(self):
@@ -134,6 +135,8 @@ class BirdSighting(models.Model):
return self.bird.common_name
def save(self):
+ if not self.point:
+ self.point = BirdSighting.objects.latest().point
try:
self.location = Location.objects.filter(
geometry__contains=self.point
diff --git a/design/sass/_homepage.scss b/design/sass/_homepage.scss
index c7ac8c3..ecf4eb5 100644
--- a/design/sass/_homepage.scss
+++ b/design/sass/_homepage.scss
@@ -260,7 +260,6 @@
.hero--wrapper {
@include breakpoint(gamma) {
margin-top: -245px;
- //margin-top: -222px;
}
}
}