summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/birds/admin.py22
-rw-r--r--app/birds/migrations/0007_auto_20170821_1415.py36
-rw-r--r--app/birds/migrations/0008_auto_20170821_1418.py20
-rw-r--r--app/birds/migrations/0009_auto_20170821_1429.py20
-rw-r--r--app/birds/migrations/0010_auto_20170906_2100.py25
-rw-r--r--app/jrnl/admin.py8
-rw-r--r--app/photos/forms.py30
-rw-r--r--app/utils/util.py15
-rw-r--r--app/utils/widgets.py1
9 files changed, 150 insertions, 27 deletions
diff --git a/app/birds/admin.py b/app/birds/admin.py
index aa2aabb..b5c6a7e 100644
--- a/app/birds/admin.py
+++ b/app/birds/admin.py
@@ -1,22 +1,9 @@
from django.contrib import admin
from django.contrib.gis.admin import OSMGeoAdmin
from birds.models import BirdSighting, BirdAudio, BirdClass, Bird
-from django.contrib.gis.geos import GEOSGeometry
from photos.forms import GalleryForm
-from daily.models import CheckIn
-
-
-def convertll(lat, lon):
- pnt = GEOSGeometry('POINT({0} {1})'.format(lon, lat), srid=4326)
- pnt.transform(3857)
- return pnt.y, pnt.x
-
-
-def get_latlon():
- loc = CheckIn.objects.latest()
- lat_converted, lon_converted = convertll(loc.lat, loc.lon)
- return lat_converted, lon_converted
+from utils.util import get_latlon
class BirdClassAdmin(admin.ModelAdmin):
@@ -31,9 +18,14 @@ class BirdAdmin(admin.ModelAdmin):
list_display = ('pk', 'common_name', 'scientific_name', 'code', 'bird_class')
list_filter = ('bird_class',)
+class GalleryFormPlus(GalleryForm):
+ def __init__(self, *args, **kwargs):
+ super(GalleryFormPlus, self).__init__(*args, **kwargs)
+ self.base_fields['seen_by'].widget = CustomSelectMultiple()
+
class BirdSightingAdmin(OSMGeoAdmin):
- form = GalleryForm
+ form = GalleryFormPlus
list_filter = (
)
list_display = ('bird', 'location')
diff --git a/app/birds/migrations/0007_auto_20170821_1415.py b/app/birds/migrations/0007_auto_20170821_1415.py
new file mode 100644
index 0000000..a51776c
--- /dev/null
+++ b/app/birds/migrations/0007_auto_20170821_1415.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2017-08-21 14:15
+from __future__ import unicode_literals
+
+import django.contrib.gis.db.models.fields
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('photos', '0018_auto_20161130_1218'),
+ ('birds', '0006_auto_20170714_2224'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='birdsighting',
+ options={'get_latest_by': 'date', 'verbose_name_plural': 'Bird Sighting'},
+ ),
+ migrations.RemoveField(
+ model_name='birdsighting',
+ name='images',
+ ),
+ migrations.AddField(
+ model_name='birdsighting',
+ name='image',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='photos.LuxImage'),
+ ),
+ migrations.AlterField(
+ model_name='birdsighting',
+ name='point',
+ field=django.contrib.gis.db.models.fields.PointField(blank=True, srid=4326),
+ ),
+ ]
diff --git a/app/birds/migrations/0008_auto_20170821_1418.py b/app/birds/migrations/0008_auto_20170821_1418.py
new file mode 100644
index 0000000..e5c80a4
--- /dev/null
+++ b/app/birds/migrations/0008_auto_20170821_1418.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2017-08-21 14:18
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('birds', '0007_auto_20170821_1415'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='birdsighting',
+ old_name='image',
+ new_name='images',
+ ),
+ ]
diff --git a/app/birds/migrations/0009_auto_20170821_1429.py b/app/birds/migrations/0009_auto_20170821_1429.py
new file mode 100644
index 0000000..840d7d3
--- /dev/null
+++ b/app/birds/migrations/0009_auto_20170821_1429.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2017-08-21 14:29
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('birds', '0008_auto_20170821_1418'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='birdsighting',
+ old_name='images',
+ new_name='image',
+ ),
+ ]
diff --git a/app/birds/migrations/0010_auto_20170906_2100.py b/app/birds/migrations/0010_auto_20170906_2100.py
new file mode 100644
index 0000000..aada189
--- /dev/null
+++ b/app/birds/migrations/0010_auto_20170906_2100.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2017-09-06 21:00
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('photos', '0018_auto_20161130_1218'),
+ ('birds', '0009_auto_20170821_1429'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='birdsighting',
+ name='image',
+ ),
+ migrations.AddField(
+ model_name='birdsighting',
+ name='images',
+ field=models.ManyToManyField(blank=True, to='photos.LuxImage'),
+ ),
+ ]
diff --git a/app/jrnl/admin.py b/app/jrnl/admin.py
index e71b733..e2b6c0b 100644
--- a/app/jrnl/admin.py
+++ b/app/jrnl/admin.py
@@ -6,6 +6,7 @@ from utils.widgets import AdminImageWidget, LGEntryForm
from .models import Entry, HomepageCurrator
from photos.forms import GalleryForm
+from utils.util import get_latlon
@admin.register(Entry)
@@ -51,9 +52,10 @@ class EntryAdmin(OSMGeoAdmin):
}),
)
# options for OSM map Using custom ESRI topo map
- default_lon = -9285175
- default_lat = 4025046
- default_zoom = 6
+ lat, lon = get_latlon()
+ default_lon = lon
+ default_lat = lat
+ default_zoom = 10
units = True
scrollable = False
map_width = 700
diff --git a/app/photos/forms.py b/app/photos/forms.py
index 9fd5529..97359e0 100644
--- a/app/photos/forms.py
+++ b/app/photos/forms.py
@@ -34,20 +34,32 @@ class GalleryForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(GalleryForm, self).__init__(*args, **kwargs)
+ self.fields['images'].choices = [(image.id, mark_safe('%sqq%sqq%s' % (image.title, image.get_image_by_size('tn'), image.pk))) for image in LuxImage.objects.all()]
+ self.fields['images'].allow_tags = True
- images = LuxImage.objects.all()[:100]
- items = []
- for image in images:
- items.append(
- (image.pk, mark_safe('%sqq%sqq%s' % (image.title, image.get_image_by_size('tn'), image.pk)))
- )
-
+from django.utils.safestring import mark_safe
+
+class ImageChoiceField(forms.ModelMultipleChoiceField):
+
+ def label_from_instance(self, obj):
+
+ return mark_safe('%sqq%sqq%s' % (obj.title, obj.get_image_by_size('tn'), obj.pk))
- self.fields['images'].choices = items
- self.fields['images'].allow_tags = True
+class FKGalleryForm(forms.ModelForm):
+ class Meta:
+ fields = '__all__'
+ widgets = {
+ 'image': ImageChoiceField(queryset=LuxImage.objects.all()),
+ }
+
+ def __init__(self, *args, **kwargs):
+ super(FKGalleryForm, self).__init__(*args, **kwargs)
+ self.fields['image'].choices = [(o.id, str(o.image.url)) for o in LuxImage.objects.all()]
+ self.fields['image'].allow_tags = True
+
class UploadZipForm(forms.Form):
"""
Handles the uploading of a gallery of photos packed in a .zip file
diff --git a/app/utils/util.py b/app/utils/util.py
new file mode 100644
index 0000000..3da6d06
--- /dev/null
+++ b/app/utils/util.py
@@ -0,0 +1,15 @@
+from daily.models import CheckIn
+from django.contrib.gis.geos import GEOSGeometry
+
+
+def convertll(lat, lon):
+ pnt = GEOSGeometry('POINT({0} {1})'.format(lon, lat), srid=4326)
+ pnt.transform(3857)
+ return pnt.y, pnt.x
+
+
+def get_latlon():
+ loc = CheckIn.objects.latest()
+ lat_converted, lon_converted = convertll(loc.lat, loc.lon)
+ return lat_converted, lon_converted
+
diff --git a/app/utils/widgets.py b/app/utils/widgets.py
index 8e390d5..240820a 100644
--- a/app/utils/widgets.py
+++ b/app/utils/widgets.py
@@ -5,6 +5,7 @@ from django.contrib.admin.widgets import AdminFileWidget
from django.contrib.gis.admin import OSMGeoAdmin
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
+from django.forms.widgets import SelectMultiple
from django.conf import settings
import markdown